real time control for wheelchair with interupt

Dependencies:   wheelchaircontrol

Files at this revision

API Documentation at this revision

Comitter:
ryanlin97
Date:
Wed Aug 15 17:13:55 2018 +0000
Parent:
5:90bf5f0d86e9
Commit message:
added on and off

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 90bf5f0d86e9 -r e9b1684a9c00 main.cpp
--- a/main.cpp	Mon Aug 13 21:54:37 2018 +0000
+++ b/main.cpp	Wed Aug 15 17:13:55 2018 +0000
@@ -3,11 +3,11 @@
 AnalogIn x(A0);
 AnalogIn y(A1);
 
-DigitalOut off(D0);
-DigitalOut on(D1);
 DigitalOut up(D2);
 DigitalOut down(D3);
-]
+DigitalOut on(D12);
+DigitalOut off(D11);
+
 bool manual = false;
 
 Serial pc(USBTX, USBRX, 57600);
@@ -19,12 +19,6 @@
 Wheelchair smart(xDir,yDir, &pc, &t);
 Thread thread;
 
-void messageCb(const std_msgs::String& command){
-    myled = 1;   // turn on the led
-    commandRead.data = command.data;
-}
-
-ros::Subscriber<std_msgs::String> sub("toggle_led", &messageCb);
 
 int main(void)
 {
@@ -75,9 +69,17 @@
                     smart.pid_turn(angle);
                 }
 
-            }
-
-            else if( c == 'm' || manual) {
+            } else if(c == 'o') {
+                pc.printf("turning on\n");
+                on = 1;
+                wait(1);
+                on = 0;
+            } else if(c == 'f') {
+                pc.printf("turning off\n");
+                off = 1;
+                wait(1);
+                off = 0;
+            } else if( c == 'm' || manual) {
                 pc.printf("turning on joystick\n");
                 manual = true;
                 t.reset();