Ger Roche
/
interupt
lab report 1
main.cpp@0:3c54226368a9, 2019-05-24 (annotated)
- Committer:
- GerRoche
- Date:
- Fri May 24 14:41:03 2019 +0000
- Revision:
- 0:3c54226368a9
Interupt
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
GerRoche | 0:3c54226368a9 | 1 | #include "mbed.h" |
GerRoche | 0:3c54226368a9 | 2 | |
GerRoche | 0:3c54226368a9 | 3 | Serial pc(USBTX, USBRX); |
GerRoche | 0:3c54226368a9 | 4 | InterruptIn button1 (p12); |
GerRoche | 0:3c54226368a9 | 5 | InterruptIn button2 (p13); |
GerRoche | 0:3c54226368a9 | 6 | InterruptIn button3 (p14); |
GerRoche | 0:3c54226368a9 | 7 | InterruptIn button4 (p15); |
GerRoche | 0:3c54226368a9 | 8 | InterruptIn button5 (p16); |
GerRoche | 0:3c54226368a9 | 9 | |
GerRoche | 0:3c54226368a9 | 10 | int down=0; |
GerRoche | 0:3c54226368a9 | 11 | int left=0; |
GerRoche | 0:3c54226368a9 | 12 | int center=0; |
GerRoche | 0:3c54226368a9 | 13 | int up=0; |
GerRoche | 0:3c54226368a9 | 14 | int right=0; |
GerRoche | 0:3c54226368a9 | 15 | |
GerRoche | 0:3c54226368a9 | 16 | void down_check() |
GerRoche | 0:3c54226368a9 | 17 | { |
GerRoche | 0:3c54226368a9 | 18 | printf("Joystick is pressed towards DOWN direction\n\r"); |
GerRoche | 0:3c54226368a9 | 19 | wait (3); |
GerRoche | 0:3c54226368a9 | 20 | } |
GerRoche | 0:3c54226368a9 | 21 | void left_check() |
GerRoche | 0:3c54226368a9 | 22 | { |
GerRoche | 0:3c54226368a9 | 23 | printf("Joystick is pressed towards LEFT direction\n\r"); |
GerRoche | 0:3c54226368a9 | 24 | wait (3); |
GerRoche | 0:3c54226368a9 | 25 | } |
GerRoche | 0:3c54226368a9 | 26 | void center_check() |
GerRoche | 0:3c54226368a9 | 27 | { |
GerRoche | 0:3c54226368a9 | 28 | printf("Joystick is pressed towards CENTER direction\n\r"); |
GerRoche | 0:3c54226368a9 | 29 | wait (3); |
GerRoche | 0:3c54226368a9 | 30 | } |
GerRoche | 0:3c54226368a9 | 31 | void up_check() |
GerRoche | 0:3c54226368a9 | 32 | { |
GerRoche | 0:3c54226368a9 | 33 | printf("Joystick is pressed towards UP direction\n\r"); |
GerRoche | 0:3c54226368a9 | 34 | wait (3); |
GerRoche | 0:3c54226368a9 | 35 | } |
GerRoche | 0:3c54226368a9 | 36 | void right_check() |
GerRoche | 0:3c54226368a9 | 37 | { |
GerRoche | 0:3c54226368a9 | 38 | printf("Joystick is pressed towards RIGHT direction\n\r"); |
GerRoche | 0:3c54226368a9 | 39 | wait (3); |
GerRoche | 0:3c54226368a9 | 40 | } |
GerRoche | 0:3c54226368a9 | 41 | |
GerRoche | 0:3c54226368a9 | 42 | int main() |
GerRoche | 0:3c54226368a9 | 43 | { |
GerRoche | 0:3c54226368a9 | 44 | //timer_temp start(); |
GerRoche | 0:3c54226368a9 | 45 | button1.rise (&down_check); |
GerRoche | 0:3c54226368a9 | 46 | button2.rise (&left_check); |
GerRoche | 0:3c54226368a9 | 47 | button3.rise (¢er_check); |
GerRoche | 0:3c54226368a9 | 48 | button4.rise (&up_check); |
GerRoche | 0:3c54226368a9 | 49 | button5.rise (&right_check); |
GerRoche | 0:3c54226368a9 | 50 | } |
GerRoche | 0:3c54226368a9 | 51 |