Game controller for FUJI CAR driving game. Dominic Cincione, Zach Gima, Max Micali.
Dependencies: DebounceIn USBDevice mbed
Fork of mouseTest by
Diff: main.cpp
- Revision:
- 2:c67ad98122e0
- Parent:
- 1:7b6bc8042945
--- 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);