Presentation code for PROJECT #1 - ES200 Fall 2014

Dependencies:   Servo mbed Motor

Files at this revision

API Documentation at this revision

Comitter:
tsevcik08
Date:
Mon Oct 20 00:54:06 2014 +0000
Parent:
6:18052a74ae56
Child:
8:30eb49981a91
Commit message:
final !!

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Oct 20 00:09:10 2014 +0000
+++ b/main.cpp	Mon Oct 20 00:54:06 2014 +0000
@@ -14,18 +14,24 @@
 DigitalIn sw3(p18); //dump
 DigitalIn sw4(p19);
 DigitalIn sw5(p20);
-DigitalOut sarah[5] = {p5, p6, p7, p8, p11};
+BusOut w(p5, p6, p7, p8, p11);  //data bus for LEDs
 
 
 int main()
 {
 
+    int switch1;
+    int switch2;
+    
+    
+
     float armpos;
     float servopos;
     float mspeed;
-
-
+    w = 16;
     while(1) {
+        switch1 = sw1.read(); //stores input from sw1 and sw2, constantly updating inside the loop
+        switch2 = sw2.read();
         if( sw4 == 1 && sw5 == 0 && sw1 == 0 && sw2 == 0 ) {
             mspeed = 0.35;
             kate.speed(mspeed);
@@ -33,7 +39,10 @@
             mspeed = 0.0;
             kate.speed(mspeed);
             wait(.05);
-            sarah[3] = 1;
+            
+            if(w == 0)
+                w=16;
+            w = w/2;    //moves LED to the right by changing binary value
         } else if( sw5 == 1 && sw4 == 0 && sw1 == 0 && sw2 == 0) {
             mspeed = -0.35;
             kate.speed(mspeed);
@@ -41,19 +50,30 @@
             mspeed = 0.0;
             kate.speed(mspeed);
             wait(.05);
+            
+            if(w == 16 )
+                w=1;
+            w = w*2;
         } else if (sw3 == 1 && sw2 == 0 && sw1 == 0 && sw4 == 0 && sw5 == 0 ) {
             for (servopos = 0; servopos <= 0.5; servopos += 0.5) {
                 scoop = servopos;
+                w = 8;
             }
             wait (1);
         } else if(sw1 == 1 && sw2 == 0 && sw5 == 0 && sw4 == 0 ) {
-            armpos += .01;
+            armpos += .02;
             arm = armpos;
             wait(.05);
+            w=31;
+            wait(.05);
+            w= 0;
         } else if(sw2 == 1 && sw1 == 0 && sw4 == 0 && sw5 == 0) {
-            armpos -= .01;
+            armpos -= .1;
             arm = armpos;
             wait(.05);
+            w=3;
+            wait(.25);
+            w=28;
         } else if (sw4 == 0 && sw1 == 0 && sw2 == 0 && sw3 == 0 && sw5 == 0) {
             mspeed = 0.0;
             kate.speed(mspeed);