chetan chowdary
/
subway_surfsfinal
Getting the real feel of subway Surfs.
main.cpp
- Committer:
- chetan133
- Date:
- 2017-03-22
- Revision:
- 0:6f645104ab31
File content as of revision 0:6f645104ab31:
#include "mbed.h" #include "USBKeyboard.h" //making virtual ketboard #include "USBSerial.h" //Virtual serial port over USB AnalogIn inputx(p20); // input pins 20,19,18 for x,y,z axis of ADXL335 respectively. AnalogIn inputy(p19); AnalogIn inputz(p18); Serial pc(USBTX,USBRX); //Serial class for transmission of serial data USBKeyboard keyboard; // setting variable DigitalOut myled1(LED1); int main() { int x=0,y=0,z=0,a=0,b=0; // variables for x,y,z axes while(1) {pc.baud(9600); //serial communication rate between pc and mbed. x=inputx*100+1; y=inputy*100-2; z=inputz*100; myled1=!myled1; pc.printf("%d,%d,%d * ",x,y,z); if(y<=52&&y>=48) { a=0; } if(y>54&&a==0) { keyboard.keyCode(RIGHT_ARROW); a=1; } if(y<46&&a==0) { keyboard.keyCode(LEFT_ARROW); a=1; } if(x>=48&&x<=52) { b=0; } if(x<46&&b==0) { keyboard.keyCode(DOWN_ARROW); b=1; } if(x>54&&b==0) { keyboard.keyCode(UP_ARROW); b=1; } } }