2 buttons and 2 switches, compiles, not tested
Dependencies: mbed C12832 MMA7660 USBDevice
Diff: main.cpp
- Revision:
- 13:d29eb4570e27
- Parent:
- 12:b6a803a6450e
--- a/main.cpp Tue Oct 15 21:06:39 2019 +0000 +++ b/main.cpp Wed Oct 16 14:23:08 2019 +0000 @@ -2,29 +2,29 @@ #include "USBKeyboard.h" #include "MMA7660.h" #include "C12832.h" - + MMA7660 Accelerometer (p28,p27); - + USBKeyboard Usbkeyboard; C12832 LCD (p5,p7,p6,p8,p11); -BusOut red_led(p21); -BusOut yellow_led(p22); -BusOut blue_led(p23); -BusOut green_led(p24); - +BusOut red_led(p12); +BusOut yellow_led(p13); +BusOut blue_led(p14); +BusOut green_led(p15); + int main (void) { - + float Acc_X = 0; float Acc_Y = 0; float Acc_Z = 0; - + while (true) { - + Acc_X = Accelerometer.x (); Acc_Y = Accelerometer.y (); Acc_Z = Accelerometer.z (); - + LCD.cls (); //LCD display showing the coordinates (turn off when submitting the program as only per programing LCD.locate (0,0); LCD.printf("X Axis: %f",Acc_X); @@ -32,9 +32,9 @@ LCD.printf("Y Axis: %f",Acc_Y); LCD.locate (0,20); LCD.printf("Z Axis: %f",Acc_Z); - + wait (0.00000000001); - + if (Acc_Y>0.08) { //Y axis program Usbkeyboard.keyCode (UP_ARROW); @@ -47,12 +47,12 @@ red_led=0; yellow_led=1; - } else if (Acc_Y<0.06) { + } else if (Acc_Y<0.25) { //turn int (main); red_led=0; yellow_led=0; - } else if (Acc_Y>0.00) { + } else if (Acc_Y<-0.25) { //turn int (main); red_led=0; yellow_led=0; @@ -68,11 +68,11 @@ green_led=0; blue_led=1; - } else if (Acc_X<0.06) { + } else if (Acc_X<0.9) { green_led=0; blue_led=0; - } else if (Acc_X>0.00) { + } else if (Acc_X<-0.9) { green_led=0; blue_led=0; //turn int (main); @@ -86,43 +86,5 @@ //Ussbkeyboard.keyCode (RIGHT_ARROW); } */ - - - } - } - - //UP - /* if (Acc_X>Acc_Y) - if (Acc_Z<0.8) - if (Acc_X<0) - Usbkeyboard.keyCode (UP_ARROW); - red_led=1; - yellow_led=0; - - - if (Acc_Z<0.8) - if (Acc_X>Acc_Y) - if (Acc_X>0) - Usbkeyboard.keyCode (DOWN_ARROW); - red_led=0; - yellow_led=1; - - if (Acc_Z<0.8) - if (Acc_Y>Acc_X) - if (Acc_Y>0) - Usbkeyboard.keyCode (LEFT_ARROW); - green_led=1; - blue_led=0; - - if (Acc_Z<0.8) - if (Acc_Y>Acc_X) - if (Acc_Y<0) - Usbkeyboard.keyCode (RIGHT_ARROW); - green_led=0; - blue_led=1; - - } -} -*/ - - + } + } \ No newline at end of file