f
Dependencies: mbed
Fork of app-board-Joystick by
Revision 1:2bca33fa66a5, committed 2015-04-29
- Comitter:
- andreashatzl
- Date:
- Wed Apr 29 16:19:37 2015 +0000
- Parent:
- 0:0e4db18afd77
- Commit message:
- kreuzer
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 0e4db18afd77 -r 2bca33fa66a5 main.cpp --- a/main.cpp Mon Oct 15 13:37:36 2012 +0000 +++ b/main.cpp Wed Apr 29 16:19:37 2015 +0000 @@ -1,18 +1,53 @@ #include "mbed.h" +#define STOP 0 +#define LL 1 +#define LR 2 + +InterruptIn diUp(p15); +InterruptIn diDown(p12); +InterruptIn diStop(p14); +int direction = LL; + +BusOut doLeds(LED1,LED2,LED3,LED4); -BusIn joy(p15,p12,p13,p16); -DigitalIn fire(p14); +void stop() +{ + doLeds = 0; + direction = 0; + } -BusOut leds(LED1,LED2,LED3,LED4); +void Down() +{ + direction = LL; + } +void Up() +{ + direction = LR; + } + + + int main() { + diStop.rise(&stop); + diDown.rise(&Down); + diUp.rise(&Up); + doLeds = 0; while(1) { - if (fire) { - leds=0xf; - } else { - leds=joy; + if (direction == LL) { + if (doLeds <= 0) + doLeds = 8; + else + doLeds = doLeds>>1; + } + else if (direction == LR){ + if (doLeds <= 0) + doLeds = 1; + else + doLeds = doLeds<<1; } - wait(0.1); + if (doLeds != 0) + wait(0.5); } }