stuff

Dependencies:   mbed Servo Motor

Revision:
3:e3b0e591e976
Parent:
2:5b599e8e7e8c
Child:
4:439279a72ef4
diff -r 5b599e8e7e8c -r e3b0e591e976 confetti.cpp
--- a/confetti.cpp	Tue Oct 08 19:18:24 2019 +0000
+++ b/confetti.cpp	Tue Oct 15 17:52:08 2019 +0000
@@ -1,10 +1,72 @@
-#include "mbed.h", "motor.h", "servo.h"
+#include "mbed.h"
+#include "Motor.h"
+#include "Servo.h"
 
 
-DigitalIn switches [5] = {p10, p11, p12, p13, p14);
+DigitalIn switches [5] = {p15, p16, p17, p18, p19};
+
+Servo gun (p24);
+Servo spin (p23);
+Motor jeff (p26, p29, p30);
+int h [5];
+float i;
+
+int main ()
+{
+    i=0.5;
+    while (1) {
+        h [0] = switches [0];
+        h [1] = switches [1];
+        h [2] = switches [2];
+        h [3] = switches [3];
+        h [4] = switches [4];
 
-Servo gun (p21);
-Servo spin (p22);
-Motor jeff (p26, p29, p30);
+        // switch 1 on and 2 off
+        if ((h [0] == 1) && (h [1] ==0)) {
+            jeff.speed (0.5);
+        }
+        // switch 1 off and 2 on
+        if ((h [0] == 0) && (h [1] == 1)) {
+            jeff.speed (-0.5);
+        }
+        // switch 1 off and 2 off
+        if (((h [0] == 0) && (h [1] == 0)) || ((h [0] == 1) && (h [1] == 1)) ){
+            
+            jeff.speed (0);
+        }
+        // switch 3 on and 4 off
+        if ((h [2] == 1) && (h [3] ==0)) {
+            if (i>1.0) {
+                i=1.0;
+            }
+            spin = i;
+            wait (0.1);
+            i = i + 0.02;
+
 
-int main () {}
\ No newline at end of file
+        }
+        // switch 3 off and 4 on
+        if ((h [2] == 0) && (h [3] ==1)) {
+            if (i<0.0) {
+                i=0.0;
+            }
+            spin = i;
+            wait (0.1);
+            i = i - 0.02;
+        }
+        // switch 3 off and 4 off
+        if (((h [2] == 0) && (h [3] ==0))|| ((h [2] == 1) && (h [3] ==1))) {
+            spin = i ;
+        }
+        // switch 5 on
+        if (h [4] == 1) {
+            gun = 1.0;
+            wait (1.0);
+            gun = 0.0;
+            wait (1.0);
+        }
+
+
+
+    }
+}
\ No newline at end of file