Project 2
/
ES200_Project2_final
final
Fork of ES200_Project2_1 by
Diff: main.cpp
- Revision:
- 2:c23c90a74ac6
- Parent:
- 1:852f86d263c8
- Child:
- 3:48d837d59ae7
--- a/main.cpp Thu Oct 18 19:10:52 2018 +0000 +++ b/main.cpp Tue Oct 23 23:12:44 2018 +0000 @@ -2,8 +2,8 @@ #include "Servo.h" #include "Motor.h" -Servo myservo(p21); -Servo myservo2(p22); +Servo clamp(p21); +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); @@ -11,34 +11,38 @@ int main() { + clamp.calibrate(0.0009,90); + toppings.calibrate(0.0009, 90); while(1) { wait(0.5); - if(sw5==1) { //servo1 off + if(sw5==1) { //clamp open, dc motor off lights=31; - printf("light 5 is on\n\r"); + 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); } - else if(sw4==1) { //dc motor off + else if(sw4==1) { //dc motor off and reset toppings lights=15; - printf("light 4 is on\n\r"); + 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; } - else if(sw3==1) { //servo2 on + else if(sw3==1) { //toppings dump lights=7; - printf("light 3 is on\n\r"); + toppings=0.5; } else if(sw2==1) { //dc motor on lights=3; - printf("light 2 is on\n\r"); m.speed(1.0); } - else if(sw1==1) { //servo1 comes on + else if(sw1==1) { //clamp turns on lights=1; - printf("light 1 is on\n\r"); } else { - lights=0; //no switches on = no lights or motors on - m.speed(0.0);} + lights=0; //no switches on = no lights, DC motor off + m.speed(0.0); + } } }