John Curran
/
lab1_Digital_Interrupts_JohnCurran_T00214119
Lab Question 1 Digital Interrupts
main.cpp@0:3899a7a0bffb, 2021-04-17 (annotated)
- Committer:
- johnc89
- Date:
- Sat Apr 17 09:22:32 2021 +0000
- Revision:
- 0:3899a7a0bffb
- Child:
- 1:80741e2594b1
Lab 1 Digital Interrupts Working
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
johnc89 | 0:3899a7a0bffb | 1 | #include "mbed.h" |
johnc89 | 0:3899a7a0bffb | 2 | // Lab1 Digital Interrupts |
johnc89 | 0:3899a7a0bffb | 3 | //John Curran T00214119 |
johnc89 | 0:3899a7a0bffb | 4 | // This programs prints on Tera Term what direction the joystick is pressed |
johnc89 | 0:3899a7a0bffb | 5 | Serial pc(USBTX, USBRX); // seriqal communications tx, rx |
johnc89 | 0:3899a7a0bffb | 6 | InterruptIn UP (p15); // Press Up on Joystick |
johnc89 | 0:3899a7a0bffb | 7 | InterruptIn DOWN (p12); // Press Down on Joystick |
johnc89 | 0:3899a7a0bffb | 8 | InterruptIn LEFT (p13); // Press Up on Joystick |
johnc89 | 0:3899a7a0bffb | 9 | InterruptIn RIGHT (p16); // Press Down on Joystick |
johnc89 | 0:3899a7a0bffb | 10 | InterruptIn CENTRE (p14); // Press Down on Joystick |
johnc89 | 0:3899a7a0bffb | 11 | |
johnc89 | 0:3899a7a0bffb | 12 | int main () |
johnc89 | 0:3899a7a0bffb | 13 | { |
johnc89 | 0:3899a7a0bffb | 14 | |
johnc89 | 0:3899a7a0bffb | 15 | { |
johnc89 | 0:3899a7a0bffb | 16 | |
johnc89 | 0:3899a7a0bffb | 17 | |
johnc89 | 0:3899a7a0bffb | 18 | pc.printf ("'LAB 1 DIGITAL INTERRUPTS JOHN CURRAN T00214119'\n\r");//prints text on screen |
johnc89 | 0:3899a7a0bffb | 19 | |
johnc89 | 0:3899a7a0bffb | 20 | |
johnc89 | 0:3899a7a0bffb | 21 | while (1) { //infinite loop |
johnc89 | 0:3899a7a0bffb | 22 | |
johnc89 | 0:3899a7a0bffb | 23 | if(UP == 1) { |
johnc89 | 0:3899a7a0bffb | 24 | pc.printf ("'UP is Pressed'\n\r");//print UP on screen |
johnc89 | 0:3899a7a0bffb | 25 | } |
johnc89 | 0:3899a7a0bffb | 26 | |
johnc89 | 0:3899a7a0bffb | 27 | if(DOWN == 1) { |
johnc89 | 0:3899a7a0bffb | 28 | pc.printf ("'DOWN is Pressed'\n\r");//print DOWN on screen |
johnc89 | 0:3899a7a0bffb | 29 | } |
johnc89 | 0:3899a7a0bffb | 30 | wait (0.5); |
johnc89 | 0:3899a7a0bffb | 31 | if(LEFT == 1) { |
johnc89 | 0:3899a7a0bffb | 32 | pc.printf ("'LEFT is Pressed'\n\r");//print LEFT on screen |
johnc89 | 0:3899a7a0bffb | 33 | } |
johnc89 | 0:3899a7a0bffb | 34 | |
johnc89 | 0:3899a7a0bffb | 35 | if(RIGHT == 1) { |
johnc89 | 0:3899a7a0bffb | 36 | pc.printf ("'RIGHT is Pressed'\n\r");//print RIGHT on screen |
johnc89 | 0:3899a7a0bffb | 37 | } |
johnc89 | 0:3899a7a0bffb | 38 | |
johnc89 | 0:3899a7a0bffb | 39 | if(CENTRE == 1) { |
johnc89 | 0:3899a7a0bffb | 40 | pc.printf ("'CENTRE is Pressed'\n\r");//print CENTRE on screen |
johnc89 | 0:3899a7a0bffb | 41 | } |
johnc89 | 0:3899a7a0bffb | 42 | |
johnc89 | 0:3899a7a0bffb | 43 | |
johnc89 | 0:3899a7a0bffb | 44 | } |
johnc89 | 0:3899a7a0bffb | 45 | } |
johnc89 | 0:3899a7a0bffb | 46 | } |