wheelchair code for alexa integration
Fork of wheelchaircontrol by
Revision 12:3cf6376007c6, committed 2018-08-17
- Comitter:
- ryanlin97
- Date:
- Fri Aug 17 03:12:21 2018 +0000
- Parent:
- 11:75f0f13ff6c1
- Commit message:
- alexa code
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 75f0f13ff6c1 -r 3cf6376007c6 main.cpp --- a/main.cpp Thu Aug 16 16:42:45 2018 +0000 +++ b/main.cpp Fri Aug 17 03:12:21 2018 +0000 @@ -3,26 +3,28 @@ AnalogIn x(A0); AnalogIn y(A1); -DigitalOut off(D0); -DigitalOut on(D1); +DigitalOut on(D12); +DigitalOut off(D11); DigitalOut up(D2); DigitalOut down(D3); bool manual = false; -Serial pc(USBTX, USBRX, 57600); +Serial pc(USBTX, USBRX, 9600); Timer t; Wheelchair smart(xDir,yDir, &pc, &t); +char c = 'z'; int main(void) { - pc.printf("hello\n"); while(1) { if( pc.readable()) { - char c = pc.getc(); - pc.printf("hello\n"); + c = pc.getc(); + } + + else { if( c == 'w') { pc.printf("up \n"); smart.forward(); @@ -50,22 +52,34 @@ else if( c == 'l') { smart.turn_left(90); } + else if(c == 'o') { + pc.printf("turning on\n"); + on = 1; + wait(1); + on = 0; + c = 'z'; + } else if(c == 'f') { + pc.printf("turning off\n"); + off = 1; + wait(1); + off = 0; + c = 'z'; + } else if( c == 't') { char buffer[256]; pc.printf ("Enter a long number: "); fgets (buffer, 256, stdin); int angle = atoi (buffer); - + if(angle == 0) { pc.printf("invalid input try again\n"); - } - else { - smart.turn(angle); - } - - } - + } else { + smart.turn(angle); + } + + } + else if( c == 'm') { pc.printf("turning on joystick\n"); manual = true; @@ -83,16 +97,13 @@ } else { - pc.printf("none \n"); smart.stop(); + pc.printf("hello\n"); } } - - else { - smart.stop(); - } - wait(process); } - + wait(process); } + +