bubble blowing / Mbed 2 deprecated Useless_Box_MkII

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
dantg
Date:
Tue Oct 23 10:55:13 2018 +0000
Commit message:
Useless Box Code

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Oct 23 10:55:13 2018 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e7ca05fa8600
\ No newline at end of file