HW3- swrd
Dependencies: PinDetect_KL25Z USBDevice mbed
Fork of octasword by
Diff: main.cpp
- Revision:
- 2:082bca930f40
- Parent:
- 1:bce67ae4dbab
- Child:
- 3:0251fef04954
--- a/main.cpp Wed Sep 16 00:03:23 2015 +0000 +++ b/main.cpp Wed Sep 16 22:38:22 2015 +0000 @@ -1,13 +1,44 @@ #include "mbed.h" +#include "PinDetect.h" +#include "USBKeyboard.h" + +Serial pc(USBTX, USBRX); -DigitalOut myled(LED1); +AnalogIn x_in(A0); +AnalogIn y_in(A1); +AnalogIn z_in(A2); + +//USBKeyboard keyboard; +PinDetect start_button(D6); +PinDetect up_button(D5); +PinDetect down_button(D4); +PinDetect right_button(D8); +PinDetect left_button(D7); int main() { + pc.printf("%s", "Welcome to octa sword"); + start_button.mode(PullUp); + up_button.mode(PullUp); + down_button.mode(PullUp); + right_button.mode(PullUp); + left_button.mode(PullUp); + while(1) { - // hello - myled = 1; - wait(0.2); - myled = 0; - wait(0.2); + if (start_button == 0) { + keyboard.keyCode(32); + } else if (up_button == 0) { + keyboard.keyCode(32); + } else if (down_button == 0) { + keyboard.keyCode(32); + } else if (right_button == 0) { + keyboard.keyCode(32); + } else if (left_button == 0) { + keyboard.keyCode(32); + } + + pc.printf("x is: %f\n\r", x_in.read()); + pc.printf("y is: %f\n\r", y_in.read()); + pc.printf("z is: %f\n\r", y_in.read()); + wait(.1); } }