Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed PinDetect_KL25Z USBDevice
main.cpp
00001 #include "mbed.h" 00002 #include "PinDetect.h" 00003 #include "USBKeyboard.h" 00004 00005 //Serial pc(USBTX, USBRX); 00006 00007 AnalogIn x_in(A0); 00008 AnalogIn y_in(A1); 00009 AnalogIn z_in(A2); 00010 00011 USBKeyboard keyboard; 00012 PinDetect start_button(D6); 00013 PinDetect up_button(D5); 00014 PinDetect down_button(D4); 00015 PinDetect right_button(D8); 00016 PinDetect left_button(D7); 00017 PinDetect a_button(D9); 00018 00019 int main() { 00020 start_button.mode(PullUp); 00021 up_button.mode(PullUp); 00022 down_button.mode(PullUp); 00023 right_button.mode(PullUp); 00024 left_button.mode(PullUp); 00025 00026 while(1) { 00027 00028 if (x_in.read() > .8 || y_in.read() > .8 || z_in.read() > .8) { 00029 keyboard.printf("%s", "a"); 00030 } else if (start_button == 0) { 00031 keyboard.keyCode(32); 00032 } else if (up_button == 0) { 00033 keyboard.keyCode(UP_ARROW); 00034 } else if (down_button == 0) { 00035 keyboard.keyCode(DOWN_ARROW); 00036 } else if (right_button == 0) { 00037 keyboard.keyCode(RIGHT_ARROW); 00038 } else if (left_button == 0) { 00039 keyboard.keyCode(LEFT_ARROW); 00040 } else if (a_button ==0) { 00041 keyboard.printf("%s", "a"); 00042 } 00043 } 00044 }
Generated on Fri Aug 5 2022 04:42:42 by
1.7.2