Game controller for FUJI CAR driving game. Dominic Cincione, Zach Gima, Max Micali.
Dependencies: DebounceIn USBDevice mbed
Fork of idd_hw3_dpcinci_FUJICAR by
Revision 2:c67ad98122e0, committed 2014-09-29
- Comitter:
- dpcinci
- Date:
- Mon Sep 29 05:28:32 2014 +0000
- Parent:
- 1:7b6bc8042945
- Commit message:
- Game controller for FUJI CAR driving game. Dominic Cincione, Zach Gima, Max Micali.
Changed in this revision
DebounceIn.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DebounceIn.lib Mon Sep 29 05:28:32 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/AjK/code/DebounceIn/#31ae5cfb44a4
--- a/main.cpp Sun Sep 28 03:29:45 2014 +0000 +++ b/main.cpp Mon Sep 29 05:28:32 2014 +0000 @@ -1,15 +1,18 @@ #include "mbed.h" #include "USBMouse.h" +#include "DebounceIn.h" //Serial pc(USBTX, USBRX); AnalogIn xAxis(A3); AnalogIn yAxis(A4); -DigitalIn go(D10); +DebounceIn go(D4); + -DigitalOut led1(LED2); -DigitalOut led2(LED3); +DigitalOut led2(LED2); +DigitalOut led1(LED1); +DigitalOut led(LED3); float x = 0; float y = 0; @@ -19,46 +22,58 @@ int i = 50; -float waitTime; +uint8_t throttle; USBMouse mouse; + int main() { - led1 = 1; - led2 = 1; - xStatic = 0.7; yStatic = 0.7; - /* + while(i--){ xStatic = xAxis.read(); yStatic = yAxis.read(); - led.write(0.9); + led = 0; wait(0.01); } - led.write(1); - */ + led = 1; while(1) { + + throttle = !go.read(); + + if(throttle==1){ + led2 = 0; + led1 = 1; + } + if(throttle==0){ + led2 = 1; + led1 = 0; + } + x = (xAxis.read()-xStatic)*50; y = (yAxis.read()-yStatic)*(-50); mouse.move(x,y); + + mouse.press(throttle); - if(go==0){ - led1 = 0; - led2 = 1; + /* + if(go == 0){ + G_led = 0; + R_led = 1; } if(go==1){ - led1 = 1; - led2 = 0; + G_led = 1; + R_led = 0; } - + */ wait(0.01);