John Curran
/
lab1_Digital_Interrupts_JohnCurran_T00214119
Lab Question 1 Digital Interrupts
Diff: main.cpp
- Revision:
- 1:80741e2594b1
- Parent:
- 0:3899a7a0bffb
diff -r 3899a7a0bffb -r 80741e2594b1 main.cpp --- a/main.cpp Sat Apr 17 09:22:32 2021 +0000 +++ b/main.cpp Sat Apr 17 10:17:41 2021 +0000 @@ -1,8 +1,14 @@ #include "mbed.h" // Lab1 Digital Interrupts //John Curran T00214119 -// This programs prints on Tera Term what direction the joystick is pressed -Serial pc(USBTX, USBRX); // seriqal communications tx, rx +// Queston 1 (b)Do you see multiple lines printed even when the joystick is toggled once? Why? Why Not!? +// Question 1 (b) Answer : without a 'wait' time i do , however when i introduce a wait time i dont, +// and it will just print what direction joystick is pressed on a seperate line +// Question 1 (c) What software or hardware solution can be applied to get a decent output? +// Question 1 (c) Answer : 'wait' & 'timers' can be used, a capacitor can be used across the switch, 'debounce' can be used + +// This programs prints on Tera Term what direction the joystick is pressed +Serial pc(USBTX, USBRX); // serial communications tx, rx InterruptIn UP (p15); // Press Up on Joystick InterruptIn DOWN (p12); // Press Down on Joystick InterruptIn LEFT (p13); // Press Up on Joystick @@ -23,7 +29,7 @@ if(UP == 1) { pc.printf ("'UP is Pressed'\n\r");//print UP on screen } - + if(DOWN == 1) { pc.printf ("'DOWN is Pressed'\n\r");//print DOWN on screen } @@ -31,16 +37,16 @@ if(LEFT == 1) { pc.printf ("'LEFT is Pressed'\n\r");//print LEFT on screen } - + if(RIGHT == 1) { pc.printf ("'RIGHT is Pressed'\n\r");//print RIGHT on screen } - + if(CENTRE == 1) { pc.printf ("'CENTRE is Pressed'\n\r");//print CENTRE on screen } - + } } -} \ No newline at end of file +}