embedded systems, Lab, Question 1 part A

Dependencies:   mbed

Revision:
0:b3bbfb3941ed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Aug 08 09:23:25 2020 +0000
@@ -0,0 +1,44 @@
+//embedded systems lab question 1
+//Write a program using interrupts on digital pins 12-16 (Joystick on Application board).
+// Use printf to print to terminal the direction the jostick is moved.
+// pin defined for Joystick Inputs and LED outputs as per Appliciation board.
+
+#include "mbed.h" //preprocessor command
+
+Serial pc(USBTX,USBRX);//serial communication to PC via the tx,rx
+
+InterruptIn down(p12);//down
+InterruptIn left(p13);//left
+InterruptIn center(p14);//center
+InterruptIn up(p15);//up
+InterruptIn right(p16);//right
+
+
+void Down(){
+    pc.printf("DOWN\r\n");//print, return to start position of new line
+    }
+void Left(){
+    pc.printf("LEFT\r\n");//print, return to start position of new line
+    }
+void Center(){
+    pc.printf("CENTER\r\n");//print, return to start position of new line
+    }
+void Up(){
+    pc.printf("UP\r\n");//print, return to start position of new line
+    }
+void Right(){
+    pc.printf("RIGHT\r\n");//print, return to start position of new line
+    }
+    
+int main(){//main program command
+    while (1){
+        down.rise(&Down);//interrupt on the rising edge
+        left.rise(&Left);//interupt on the rising edge
+        center.rise(&Center);//interrupt on the rising edge
+        up.rise(&Up);//interrupt on the rising edge
+        right.rise(&Right);//interrupt on the rising edge
+        down.rise(&Down);//interrupt on the rising edge
+        }
+}
+        
+        
\ No newline at end of file