bubble blowing / Mbed 2 deprecated Useless_Box_MkII

Dependencies:   mbed

Revision:
0:d18a5e3c79c9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Oct 23 10:55:13 2018 +0000
@@ -0,0 +1,34 @@
+#include "mbed.h"
+
+PwmOut Backward_Motor_Control (p22);    
+PwmOut Forward_Motor_Control (p21);
+DigitalIn Backward_Switch (p17);
+DigitalIn Forward_Switch (p18);
+DigitalIn Limit_Switch (p19);
+
+int main() {
+    
+    Backward_Motor_Control.period (0.02);   //Sets the backward motor speed to 50hz
+    Forward_Motor_Control.period (0.02);    //Sets the forward motor speed to 50hz
+    
+    while(1) {
+        if (Forward_Switch.read() == 1) {   //When a person presses the switch
+            Forward_Motor_Control = 0.5;    //Motor moves forward at a steady speed
+            Backward_Motor_Control = 0;
+            wait (0.1);  //Pause to allow time for the PWM signal
+        }
+        else if (Backward_Switch.read() == 1 && Limit_Switch.read() == 0) { //When the arm presses the switch
+            Forward_Motor_Control = 0;  //Motor moves backwards at a steady speed
+            Backward_Motor_Control = 0.5;
+            wait (0.1);   //Pause to allow time for the PWM signal  
+        }
+        else if (Backward_Switch.read() == 1 && Limit_Switch.read() == 1) { //When the arm presses the limit switch
+            Forward_Motor_Control = 0;  //Motor stops moving
+            Backward_Motor_Control = 0;
+            wait (0.1);     //Pause to allow time for the PWM signal
+        }
+    }
+}
+  
+    
+    
\ No newline at end of file