Ger Roche / Mbed 2 deprecated mbed_Lab1_Joystick2

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
GerRoche
Date:
Fri May 24 15:06:46 2019 +0000
Parent:
2:426f7c929554
Commit message:
Lab1.2

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu May 23 20:51:49 2019 +0000
+++ b/main.cpp	Fri May 24 15:06:46 2019 +0000
@@ -1,11 +1,17 @@
 #include "mbed.h"//includes mbed header
 
-Serial pc(USBTX,USBRX);// sets up serial connection to PC
-InterruptIn DN(p12);// declares p12 as an intrrupt In called DN
-InterruptIn LH(p13);// declares p13 as an intrrupt In called LH
-InterruptIn CN(p14);// declares p14 as an intrrupt In called CN
-InterruptIn UP(p15);// declares p15 as an intrrupt In called UP
-InterruptIn RH(p16);// declares p16 as an intrrupt In called RH
+Serial pc(USBTX,  USBRX);
+InterruptIn button1 (p12);
+InterruptIn button2 (p13);
+InterruptIn button3 (p14);
+InterruptIn button4 (p15);
+InterruptIn button5 (p16);
+
+int down=0;
+int left=0;
+int center=0;
+int up=0;
+int right=0;
 
 void print1()
 {
@@ -36,11 +42,11 @@
 int main()
 {
     printf("Hello\r\n");// prints "Hello" at the top of the screen
-    DN.rise(&print1);// prints first print statment when value goes from 0V to 3.3V and p12 is hit
-    LH.rise(&print2);// prints second print statment when value goes from 0V to 3.3V and p13 is hit
-    CN.rise(&print3);// prints third print statment when value goes from 0V to 3.3V and p14 is hit
-    UP.rise(&print4);// prints fourth print statment when value goes from 0V to 3.3V and p15 is hit
-    RH.rise(&print5);// prints fifth print statment when value goes from 0V to 3.3V and p16 is hit
+    1.rise(&print1);// prints first print statment when value goes from 0V to 3.3V and p12 is hit
+    2.rise(&print2);// prints second print statment when value goes from 0V to 3.3V and p13 is hit
+    3.rise(&print3);// prints third print statment when value goes from 0V to 3.3V and p14 is hit
+    4.rise(&print4);// prints fourth print statment when value goes from 0V to 3.3V and p15 is hit
+    5.rise(&print5);// prints fifth print statment when value goes from 0V to 3.3V and p16 is hit
     wait(0.5);// waits 0.5 seconds
     while(1) {