HW3- swrd

Dependencies:   PinDetect_KL25Z USBDevice mbed

Fork of octasword by TONY WU

Files at this revision

API Documentation at this revision

Comitter:
twuster
Date:
Mon Sep 21 04:46:29 2015 +0000
Parent:
3:0251fef04954
Commit message:
finished

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 0251fef04954 -r 3a66333d6cf0 main.cpp
--- a/main.cpp	Sun Sep 20 22:21:33 2015 +0000
+++ b/main.cpp	Mon Sep 21 04:46:29 2015 +0000
@@ -9,12 +9,12 @@
 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);
-PinDetect a_button(D9);
+PinDetect start_button(D13);
+PinDetect up_button(D8);
+PinDetect down_button(D9);
+PinDetect right_button(D10);
+PinDetect left_button(D12);
+PinDetect select_button(D11);
 
 int main() {
     start_button.mode(PullUp);
@@ -24,8 +24,13 @@
     left_button.mode(PullUp);
     
     while(1) {
+//        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", z_in.read());
         
-        if (x_in.read() > .8 || y_in.read() > .8 || z_in.read() > .8) {
+//        wait(.5);
+        
+        if (x_in.read() > .65 || x_in.read() < .35 || y_in.read() > .65 || y_in.read() < .35 || z_in.read() > .65 || z_in.read() < .35) {
             keyboard.printf("%s", "a");
         } else if (start_button == 0) {
             keyboard.keyCode(32);
@@ -37,7 +42,7 @@
             keyboard.keyCode(RIGHT_ARROW);
         } else if (left_button == 0) {
             keyboard.keyCode(LEFT_ARROW);
-        } else if (a_button ==0) {
+        } else if (select_button ==0) {
             keyboard.printf("%s", "a");
         }
     }