2 buttons and 2 switches, compiles, not tested
Dependencies: mbed C12832 MMA7660 USBDevice
Diff: main.cpp
- Revision:
- 14:116f94a428c9
- Parent:
- 11:73e8c1bb5467
- Child:
- 15:19bac11ed885
--- a/main.cpp Thu Oct 10 20:03:05 2019 +0000 +++ b/main.cpp Thu Oct 17 19:10:26 2019 +0000 @@ -6,10 +6,49 @@ MMA7660 Accelerometer (p28,p27); USBKeyboard Usbkeyboard; C12832 LCD (p5,p7,p6,p8,p11); +DigitalOut led(p23); + + int main (void) { - + //enum Orientation {Up, Down,Right, Left,Back, Front,Unknown}; + MMA7660::Orientation myOrientation; + + while (true) { + + myOrientation = Accelerometer.getOrientation (); + + if (myOrientation == MMA7660::Up){ + + LCD.printf("Up"); + Usbkeyboard.keyCode (UP_ARROW); + } + else if (myOrientation == MMA7660::Down){ + + LCD.printf("Down"); + Usbkeyboard.keyCode (DOWN_ARROW); + } + else if (myOrientation == MMA7660::Left){ + + LCD.printf("Left"); + Usbkeyboard.keyCode (LEFT_ARROW); + } + else if (myOrientation == MMA7660::Right){ + + LCD.printf("Right"); + Usbkeyboard.keyCode (RIGHT_ARROW); + } + else if (myOrientation == MMA7660::Front){ + + LCD.printf("Front"); + } + else if (myOrientation == MMA7660::Unknown){ + + LCD.printf("Don't Know"); + } + +/* float Acc_X = 0; float Acc_Y = 0; float Acc_Z = 0; @@ -30,6 +69,8 @@ wait (0.00000000001); + if (led=1); + if (Acc_Y>0.08) { //Y axis program // Usbkeyboard.printf("w\0"); Usbkeyboard.keyCode (UP_ARROW); @@ -53,6 +94,6 @@ //Ussbkeyboard.keyCode (RIGHT_ARROW); } */ - } + } return false; }