HW3- swrd
Dependencies: PinDetect_KL25Z USBDevice mbed
Fork of octasword by
Revision 2:082bca930f40, committed 2015-09-16
- Comitter:
- twuster
- Date:
- Wed Sep 16 22:38:22 2015 +0000
- Parent:
- 1:bce67ae4dbab
- Child:
- 3:0251fef04954
- Commit message:
- usbkeyboard strugglez
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PinDetect_KL25Z.lib Wed Sep 16 22:38:22 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/bjo3rn/code/PinDetect_KL25Z/#4f11ae3737c7
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/USBDevice.lib Wed Sep 16 22:38:22 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/mjr/code/USBDevice/#a8eb758f4074
--- 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); } }