linear actuator

Dependencies:   Motor PinDetect mbed

Fork of xbee_robot by Shubhojit Chattopadhyay

Revision:
4:580ea208038b
Parent:
3:473269e5a06f
Child:
5:a1b28b06425a
--- a/main.cpp	Wed Feb 24 16:52:04 2016 +0000
+++ b/main.cpp	Fri Feb 26 20:49:08 2016 +0000
@@ -1,5 +1,5 @@
 //Linear Actuator to control the moving rod. 
-/*
+
 #include "mbed.h"
 #include "Motor.h"
 #include "PinDetect.h"
@@ -10,8 +10,9 @@
 float wait_time = 3.0;               //time waiting for the drone to slide to the triangle hindge
 float hold_time = 3.0;               //the time during which the Table Actuator will stay at its highest position after disconnected the connector
 int running_schedule = 0;            //0-resting  1-running the schedule
-int reset = 0;
+int is_reset = 0;
 
+DigitalOut led(LED1);
 Motor m1(p21, p27, p28);        // pwm, fwd, rev //Table Actuator
 Motor m2(p22, p10, p9);          // pwm, fwd, rev //Connector Actuator
 PinDetect load_sensor(p5);
@@ -19,7 +20,8 @@
 PinDetect reset(p7);
 
 void start_the_schedule(){
-    running_schedule = 1;       //when the load sensor sense the drone or the start putton is pressed, change to 1;    
+    running_schedule = 1;       //when the load sensor sense the drone or the start putton is pressed, change to 1;
+    led = !led;    
 }
 
 void reset_to_zero(){
@@ -32,15 +34,6 @@
 }
 
 
-void reset_to_zero(){
-    reset = 1;                 //reset now gets priority
-    m2.speed(-1); 
-    m1.speed(-1);             //Connector Actuator Goging down
-    wait(moving_time2);
-    m2.speed(0);              //Connector Actuator Stops at the start position
-    m1.speed(0);              //Table Actuator Stops at the start position
-}
-
 int main() {
     load_sensor.mode(PullUp); wait(0.01);
     load_sensor.attach_deasserted(&start_the_schedule);
@@ -52,7 +45,14 @@
     reset.attach_deasserted(&reset_to_zero);
     reset.setSampleFrequency();
     
+   
     while(1) {
+        // m1.speed(-1);           //Connector Actuator Goging down
+        //wait(moving_time1);
+        //m1.speed(0);
+        m2.speed(-1);           //Connector Actuator Goging down
+            wait(moving_time2);
+            m2.speed(0); 
         while(running_schedule){
             if(reset) break;
             m1.speed(1);            //Table Actuator Going Up
@@ -78,13 +78,13 @@
             m1.speed(0);            //Table Actuator Stops at the start position
             running_schedule = 0;   //change back to resting after finished the whole loop
         }
-        reset = 0;                  //Either finishe the schedual natually, or break from the loop, set reset back to 0
+        is_reset = 0;                  //Either finishe the schedual natually, or break from the loop, set reset back to 0
         running_schedule = 0;       //and rest the system 
     }  
   
 }
 
-*/
+/*
 
 #include "mbed.h"
 #include "Motor.h"
@@ -198,10 +198,11 @@
     reset.attach_deasserted(&break_loop);
     reset.setSampleFrequency();
     while(1){
+        
         if(running_schedule){
             schedule();
             running_schedule = 0;       //return to reset after finish the schedule
         }
     }
 }
-
+*/