![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
wheelchair code for alexa integration
Fork of wheelchaircontrol by
main.cpp@2:c2d049efc266, 2018-07-12 (annotated)
- Committer:
- ryanlin97
- Date:
- Thu Jul 12 20:51:54 2018 +0000
- Revision:
- 2:c2d049efc266
- Parent:
- 1:c0beadca1617
- Child:
- 3:a5e71bfdb492
switched mbed-os for mbed package and it compiles now;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ryanlin97 | 0:fc0c4a184482 | 1 | #include "wheelchair.h" |
ryanlin97 | 0:fc0c4a184482 | 2 | |
ryanlin97 | 0:fc0c4a184482 | 3 | Serial pc(USBTX, USBRX); |
ryanlin97 | 0:fc0c4a184482 | 4 | |
ryanlin97 | 0:fc0c4a184482 | 5 | DigitalOut off(D0); |
ryanlin97 | 0:fc0c4a184482 | 6 | DigitalOut on(D1); |
ryanlin97 | 0:fc0c4a184482 | 7 | DigitalOut up(D2); |
ryanlin97 | 0:fc0c4a184482 | 8 | DigitalOut down(D3); |
ryanlin97 | 2:c2d049efc266 | 9 | |
ryanlin97 | 2:c2d049efc266 | 10 | Wheelchair smart(xDir,yDir); |
ryanlin97 | 2:c2d049efc266 | 11 | |
ryanlin97 | 0:fc0c4a184482 | 12 | int main(void) |
ryanlin97 | 0:fc0c4a184482 | 13 | { |
ryanlin97 | 0:fc0c4a184482 | 14 | on = 1; |
ryanlin97 | 2:c2d049efc266 | 15 | while(1){ |
ryanlin97 | 2:c2d049efc266 | 16 | if( pc.readable()) { |
ryanlin97 | 2:c2d049efc266 | 17 | char c = pc.getc(); |
ryanlin97 | 2:c2d049efc266 | 18 | if( c == 'w') { |
ryanlin97 | 2:c2d049efc266 | 19 | pc.printf("up \n"); |
ryanlin97 | 2:c2d049efc266 | 20 | smart.forward(); |
ryanlin97 | 0:fc0c4a184482 | 21 | } |
ryanlin97 | 2:c2d049efc266 | 22 | |
ryanlin97 | 2:c2d049efc266 | 23 | else if( c == 'd') { |
ryanlin97 | 2:c2d049efc266 | 24 | pc.printf("left \n"); |
ryanlin97 | 2:c2d049efc266 | 25 | smart.left(); |
ryanlin97 | 0:fc0c4a184482 | 26 | } |
ryanlin97 | 2:c2d049efc266 | 27 | |
ryanlin97 | 2:c2d049efc266 | 28 | else if( c == 'a') { |
ryanlin97 | 2:c2d049efc266 | 29 | pc.printf("right \n"); |
ryanlin97 | 2:c2d049efc266 | 30 | smart.right(); |
ryanlin97 | 0:fc0c4a184482 | 31 | } |
ryanlin97 | 2:c2d049efc266 | 32 | |
ryanlin97 | 2:c2d049efc266 | 33 | else if( c == 's') { |
ryanlin97 | 2:c2d049efc266 | 34 | pc.printf("down \n"); |
ryanlin97 | 2:c2d049efc266 | 35 | smart.backward(); |
ryanlin97 | 0:fc0c4a184482 | 36 | } |
ryanlin97 | 2:c2d049efc266 | 37 | |
ryanlin97 | 2:c2d049efc266 | 38 | else { |
ryanlin97 | 2:c2d049efc266 | 39 | pc.printf("none \n"); |
ryanlin97 | 2:c2d049efc266 | 40 | smart.stop(); |
ryanlin97 | 2:c2d049efc266 | 41 | if( c == 'o') { |
ryanlin97 | 2:c2d049efc266 | 42 | pc.printf("turning on"); |
ryanlin97 | 2:c2d049efc266 | 43 | on = 0; |
ryanlin97 | 2:c2d049efc266 | 44 | wait(process); |
ryanlin97 | 2:c2d049efc266 | 45 | on = 1; |
ryanlin97 | 0:fc0c4a184482 | 46 | } |
ryanlin97 | 2:c2d049efc266 | 47 | |
ryanlin97 | 2:c2d049efc266 | 48 | else if( c == 'k') { |
ryanlin97 | 2:c2d049efc266 | 49 | off = 0; |
ryanlin97 | 2:c2d049efc266 | 50 | wait(process); |
ryanlin97 | 2:c2d049efc266 | 51 | off = 1; |
ryanlin97 | 0:fc0c4a184482 | 52 | } |
ryanlin97 | 2:c2d049efc266 | 53 | |
ryanlin97 | 2:c2d049efc266 | 54 | else if( c == 'u') { |
ryanlin97 | 2:c2d049efc266 | 55 | up = 0; |
ryanlin97 | 2:c2d049efc266 | 56 | wait(process); |
ryanlin97 | 2:c2d049efc266 | 57 | up = 1; |
ryanlin97 | 0:fc0c4a184482 | 58 | } |
ryanlin97 | 2:c2d049efc266 | 59 | |
ryanlin97 | 2:c2d049efc266 | 60 | else if( c == 'p') { |
ryanlin97 | 2:c2d049efc266 | 61 | down = 0; |
ryanlin97 | 2:c2d049efc266 | 62 | wait(process); |
ryanlin97 | 2:c2d049efc266 | 63 | down = 1; |
ryanlin97 | 0:fc0c4a184482 | 64 | } |
ryanlin97 | 0:fc0c4a184482 | 65 | } |
ryanlin97 | 2:c2d049efc266 | 66 | } |
ryanlin97 | 2:c2d049efc266 | 67 | |
ryanlin97 | 2:c2d049efc266 | 68 | else { |
ryanlin97 | 2:c2d049efc266 | 69 | pc.printf("Nothing pressed \n"); |
ryanlin97 | 2:c2d049efc266 | 70 | smart.stop(); |
ryanlin97 | 2:c2d049efc266 | 71 | } |
ryanlin97 | 2:c2d049efc266 | 72 | |
ryanlin97 | 2:c2d049efc266 | 73 | wait(process); |
ryanlin97 | 2:c2d049efc266 | 74 | } |
ryanlin97 | 1:c0beadca1617 | 75 | |
ryanlin97 | 0:fc0c4a184482 | 76 | } |
ryanlin97 | 0:fc0c4a184482 | 77 |