embedded systems, Lab, Question 1 part A

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
liammchale
Date:
Sat Aug 08 09:23:25 2020 +0000
Commit message:
finished with comments now included

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r b3bbfb3941ed main.cpp
--- /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
diff -r 000000000000 -r b3bbfb3941ed mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Aug 08 09:23:25 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file