final

Dependencies:   Servo1 mbed

Fork of ES200_Project2_1 by Project 2

Files at this revision

API Documentation at this revision

Comitter:
m211656
Date:
Thu Oct 25 00:36:27 2018 +0000
Parent:
2:c23c90a74ac6
Commit message:
Final code-everything should work fine

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Oct 23 23:12:44 2018 +0000
+++ b/main.cpp	Thu Oct 25 00:36:27 2018 +0000
@@ -6,38 +6,41 @@
 Servo toppings(p22);
 Motor m(p26,p30,p29);
 DigitalIn sw1(p15), sw2(p16), sw3(p17), sw4(p18), sw5(p19);
-BusOut lights(p5,p6,p7,p10,p11);
+BusOut lights(p5,p6,p7,p8,p9);
 
 
 int main()
 {
     clamp.calibrate(0.0009,90); 
     toppings.calibrate(0.0009, 90);
+    toppings=1.0;
     while(1) 
     {
         wait(0.5);
         if(sw5==1) { //clamp open, dc motor off
             lights=31;
             printf("light 5 is on\n\r");//Prof said to leave this in to prove our code works
-            clamp=0.0;
             m.speed(0.0);
+            wait(0.02);
+            clamp=0.5;
         }
-        else if(sw4==1) { //dc motor off and reset toppings
+        else if(sw4==1) { //dc motor on
             lights=15;
             printf("light 4 is on\n\r");//Prof said to leave this is to prove our code works
-            m.speed(0.0);
-            toppings=0.0;
+            m.speed(0.5);
             }
-        else if(sw3==1) { //toppings dump
+        else if(sw3==1) { //toppings return
             lights=7;
-            toppings=0.5;
+            toppings=1.0;
             }
-        else if(sw2==1) { //dc motor on
+        else if(sw2==1) { //toppings dump
             lights=3;
-            m.speed(1.0);
+            toppings=0.8;
+            
             }
         else if(sw1==1) { //clamp turns on
             lights=1;
+            clamp=0.12;
             }
         else {
             lights=0; //no switches on = no lights, DC motor off