Joystick2
Dependencies: mbed
Fork of FTKL_board-Joystick2 by
FTKL_board-Joystick2.cpp@0:1ee1d2b34ead, 2015-04-29 (annotated)
- Committer:
- Planinsec
- Date:
- Wed Apr 29 15:53:32 2015 +0000
- Revision:
- 0:1ee1d2b34ead
FTKL
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Planinsec | 0:1ee1d2b34ead | 1 | #include "mbed.h" |
Planinsec | 0:1ee1d2b34ead | 2 | |
Planinsec | 0:1ee1d2b34ead | 3 | BusIn biJoy(p15,p12,p13,p16); |
Planinsec | 0:1ee1d2b34ead | 4 | DigitalIn diFire(p14); |
Planinsec | 0:1ee1d2b34ead | 5 | |
Planinsec | 0:1ee1d2b34ead | 6 | BusOut doLeds(LED1,LED2,LED3,LED4); |
Planinsec | 0:1ee1d2b34ead | 7 | |
Planinsec | 0:1ee1d2b34ead | 8 | int main() |
Planinsec | 0:1ee1d2b34ead | 9 | { |
Planinsec | 0:1ee1d2b34ead | 10 | doLeds=0; |
Planinsec | 0:1ee1d2b34ead | 11 | |
Planinsec | 0:1ee1d2b34ead | 12 | while(1) |
Planinsec | 0:1ee1d2b34ead | 13 | { |
Planinsec | 0:1ee1d2b34ead | 14 | if (diFire) |
Planinsec | 0:1ee1d2b34ead | 15 | { |
Planinsec | 0:1ee1d2b34ead | 16 | doLeds=0; |
Planinsec | 0:1ee1d2b34ead | 17 | } |
Planinsec | 0:1ee1d2b34ead | 18 | |
Planinsec | 0:1ee1d2b34ead | 19 | if (biJoy==1) |
Planinsec | 0:1ee1d2b34ead | 20 | { |
Planinsec | 0:1ee1d2b34ead | 21 | while (1) |
Planinsec | 0:1ee1d2b34ead | 22 | { |
Planinsec | 0:1ee1d2b34ead | 23 | |
Planinsec | 0:1ee1d2b34ead | 24 | doLeds=doLeds<<1; |
Planinsec | 0:1ee1d2b34ead | 25 | |
Planinsec | 0:1ee1d2b34ead | 26 | if (doLeds==16 ||doLeds== 0) |
Planinsec | 0:1ee1d2b34ead | 27 | { |
Planinsec | 0:1ee1d2b34ead | 28 | doLeds=1; |
Planinsec | 0:1ee1d2b34ead | 29 | } |
Planinsec | 0:1ee1d2b34ead | 30 | |
Planinsec | 0:1ee1d2b34ead | 31 | if (diFire) |
Planinsec | 0:1ee1d2b34ead | 32 | { |
Planinsec | 0:1ee1d2b34ead | 33 | doLeds=0; |
Planinsec | 0:1ee1d2b34ead | 34 | break; |
Planinsec | 0:1ee1d2b34ead | 35 | } |
Planinsec | 0:1ee1d2b34ead | 36 | |
Planinsec | 0:1ee1d2b34ead | 37 | wait(0.5); |
Planinsec | 0:1ee1d2b34ead | 38 | } |
Planinsec | 0:1ee1d2b34ead | 39 | } |
Planinsec | 0:1ee1d2b34ead | 40 | |
Planinsec | 0:1ee1d2b34ead | 41 | if (biJoy==2) |
Planinsec | 0:1ee1d2b34ead | 42 | { |
Planinsec | 0:1ee1d2b34ead | 43 | while(1) |
Planinsec | 0:1ee1d2b34ead | 44 | |
Planinsec | 0:1ee1d2b34ead | 45 | { |
Planinsec | 0:1ee1d2b34ead | 46 | doLeds=doLeds>>1; |
Planinsec | 0:1ee1d2b34ead | 47 | |
Planinsec | 0:1ee1d2b34ead | 48 | |
Planinsec | 0:1ee1d2b34ead | 49 | if (doLeds==16||doLeds==0) |
Planinsec | 0:1ee1d2b34ead | 50 | { |
Planinsec | 0:1ee1d2b34ead | 51 | doLeds=8; |
Planinsec | 0:1ee1d2b34ead | 52 | } |
Planinsec | 0:1ee1d2b34ead | 53 | |
Planinsec | 0:1ee1d2b34ead | 54 | if (diFire) |
Planinsec | 0:1ee1d2b34ead | 55 | { |
Planinsec | 0:1ee1d2b34ead | 56 | doLeds=0; |
Planinsec | 0:1ee1d2b34ead | 57 | break; |
Planinsec | 0:1ee1d2b34ead | 58 | } |
Planinsec | 0:1ee1d2b34ead | 59 | |
Planinsec | 0:1ee1d2b34ead | 60 | wait(0.5); |
Planinsec | 0:1ee1d2b34ead | 61 | } |
Planinsec | 0:1ee1d2b34ead | 62 | } |
Planinsec | 0:1ee1d2b34ead | 63 | } //while 1 |
Planinsec | 0:1ee1d2b34ead | 64 | } //main |