Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: PID QEI chair_BNO055 ros_lib_kinetic
Fork of wheelchaircontrol by
Diff: main.cpp
- Revision:
- 6:0cd57bdd8fbc
- Parent:
- 5:e0ccaab3959a
- Child:
- 7:5e38d43fbce3
diff -r e0ccaab3959a -r 0cd57bdd8fbc main.cpp
--- a/main.cpp Tue Jul 17 07:19:04 2018 +0000
+++ b/main.cpp Fri Jul 20 17:54:43 2018 +0000
@@ -8,72 +8,80 @@
DigitalOut up(D2);
DigitalOut down(D3);
-Wheelchair smart(xDir,yDir);
+Serial pc(USBTX, USBRX);
+
+Wheelchair smart(xDir,yDir, &pc);
int main(void)
{
on = 1;
- 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 == 'a') {
- pc.printf("right \n");
- smart.right();
- }
-
- else if( c == 's') {
- pc.printf("down \n");
- smart.backward();
+ 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 == 'a') {
+ pc.printf("right \n");
+ smart.right();
+ }
+
+ 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 if( c == 'k') {
+ off = 0;
+ wait(process);
+ off = 1;
+ }
+
+ else if( c == 'u') {
+ up = 0;
+ wait(process);
+ up = 1;
+ }
+
+ else if( c == 'p') {
+ down = 0;
+ wait(process);
+ down = 1;
+ }
+ }
+ }
+
+ else {
+ pc.printf("Nothing pressed \n");
+ smart.stop();
+ }
+ */
+ smart.move(x,y);
+ if( pc.readable()) {
+ char c = pc.getc();
+ if( c == 'r') {
+ smart.turn_right(pc);
}
-
- 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 == 'u') {
- up = 0;
- wait(process);
- up = 1;
- }
-
- else if( c == 'p') {
- down = 0;
- wait(process);
- down = 1;
- }
- }
- }
-
- else {
- pc.printf("Nothing pressed \n");
- smart.stop();
- }
- */
- smart.move(x,y);
- wait(process);
- }
+ }
+ wait(process);
+ }
}
