idd hw3
Dependencies: mbed DebounceIn USBDevice PinDetect
Diff: main.cpp
- Revision:
- 7:7abb32ab30b6
- Parent:
- 6:adec77323ab2
- Child:
- 8:a6ff9fbacf85
--- a/main.cpp Sun Sep 28 21:56:04 2014 +0000 +++ b/main.cpp Sun Sep 28 22:02:27 2014 +0000 @@ -3,9 +3,9 @@ #include "DebounceIn.h" BusOut leds(LED1, LED2, LED3); -DebounceIn accelerate(D7); -DebounceIn powerUp(D13); -DebounceIn breakz(D6); +DebounceIn accelerate(D11); +DebounceIn powerUp(D10); +DebounceIn breakz(D13); Serial pc(USBTX, USBRX); @@ -14,10 +14,10 @@ AnalogIn accelX(A2); //USBMouseKeyboard -//USBKeyboard controller; +USBKeyboard controller; -//Y: 0.43 - 0.56 -//X: 0.39 - 0.57 +//X: 0.48 - 0.51 +//Z: 0.47 - 0.57 float CENTER_LEFT = 0.48; float CENTER_RIGHT = 0.51; float CENTER_UP = 0.47; @@ -27,44 +27,44 @@ pc.baud(115200); while (1) { if (!accelerate) { -// controller.keyCode('x'); + controller.keyCode('x'); if (accelX.read() <= CENTER_LEFT) { //controller.move(-1, 0); -// controller.keyCode(LEFT_ARROW); -// controller.keyCode('x'); + controller.keyCode(LEFT_ARROW); + controller.keyCode('x'); } if (accelX.read() >= CENTER_RIGHT) { //controller.move(1, 0); -// controller.keyCode(RIGHT_ARROW); -// controller.keyCode('x'); + controller.keyCode(RIGHT_ARROW); + controller.keyCode('x'); } } if (!powerUp) { -// controller.keyCode('x'); -// controller.keyCode('s'); -// controller.keyCode('x'); + controller.keyCode('x'); + controller.keyCode('s'); + controller.keyCode('x'); } if (!breakz) { -// controller.keyCode('z'); + controller.keyCode('z'); } // Navigation in Game Menu if (accelX.read() <= CENTER_LEFT) { -// controller.keyCode(LEFT_ARROW); + controller.keyCode(LEFT_ARROW); pc.printf("left\n"); wait(0.1); } if (accelX.read() >= CENTER_RIGHT) { -// controller.keyCode(RIGHT_ARROW); + controller.keyCode(RIGHT_ARROW); pc.printf("right\n"); wait(0.1); } if (accelZ.read() <= CENTER_UP) { -// controller.keyCode(UP_ARROW); + controller.keyCode(UP_ARROW); pc.printf("up\n"); wait(0.1); } if (accelZ.read() >= CENTER_DOWN) { -// controller.keyCode(DOWN_ARROW); + controller.keyCode(DOWN_ARROW); pc.printf("down\n"); wait(0.1); }