ryan lin
/
wheeldriveassistance
wheelchair code for driver assitance
Fork of wheelchairalexa by
Diff: main.cpp
- Revision:
- 2:c2d049efc266
- Parent:
- 1:c0beadca1617
- Child:
- 3:a5e71bfdb492
--- a/main.cpp Thu Jul 12 19:06:33 2018 +0000 +++ b/main.cpp Thu Jul 12 20:51:54 2018 +0000 @@ -6,70 +6,72 @@ DigitalOut on(D1); DigitalOut up(D2); DigitalOut down(D3); + +Wheelchair smart(xDir,yDir); + int main(void) { - Wheelchair smart(xDir,yDir); on = 1; - while(1) { - if( pc.readable()) { - char c = pc.getc(); - if( c == 'w') { - pc.printf("up \n"); - smart.forward(); + while(1){ + if( pc.readable()) { + char c = pc.getc(); + if( c == 'w') { + pc.printf("up \n"); + smart.forward(); } - - else if( c == 'd') { - pc.printf("left \n"); - smart.left(); + + else if( c == 'd') { + pc.printf("left \n"); + smart.left(); } - - else if( c == 'a') { - pc.printf("right \n"); - smart.right(); + + else if( c == 'a') { + pc.printf("right \n"); + smart.right(); } - - else if( c == 's') { - pc.printf("down \n"); - smart.backward(); + + else if( c == 's') { + pc.printf("down \n"); + smart.backward(); } - - else { - pc.printf("none \n"); - smart.stop(); - if( c == 'o') { - pc.printf("turning on"); - on = 0; - wait(process); - on = 1; + + else { + pc.printf("none \n"); + smart.stop(); + if( c == 'o') { + pc.printf("turning on"); + on = 0; + wait(process); + on = 1; } - - else if( c == 'k') { - off = 0; - wait(process); - off = 1; + + else if( c == 'k') { + off = 0; + wait(process); + off = 1; } - - else if( c == 'u') { - up = 0; - wait(process); - up = 1; + + else if( c == 'u') { + up = 0; + wait(process); + up = 1; } - - else if( c == 'p') { - down = 0; - wait(process); - down = 1; + + else if( c == 'p') { + down = 0; + wait(process); + down = 1; } } - } - - else { - pc.printf("nothing pressed \n"); - smart.stop(); - } - - wait(process); - } + } + + else { + pc.printf("Nothing pressed \n"); + smart.stop(); + } + + wait(process); + } }