Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of ES200_Project2_1 by
main.cpp
00001 #include "mbed.h" 00002 #include "Servo.h" 00003 #include "Motor.h" 00004 00005 Servo clamp(p21); 00006 Servo toppings(p22); 00007 Motor m(p26,p30,p29); 00008 DigitalIn sw1(p15), sw2(p16), sw3(p17), sw4(p18), sw5(p19); 00009 BusOut lights(p5,p6,p7,p8,p9); 00010 00011 00012 int main() 00013 { 00014 clamp.calibrate(0.0009,90); 00015 toppings.calibrate(0.0009, 90); 00016 toppings=1.0; 00017 while(1) 00018 { 00019 wait(0.5); 00020 if(sw5==1) { //clamp open, dc motor off 00021 lights=31; 00022 printf("light 5 is on\n\r");//Prof said to leave this in to prove our code works 00023 m.speed(0.0); 00024 wait(0.02); 00025 clamp=0.5; 00026 } 00027 else if(sw4==1) { //dc motor on 00028 lights=15; 00029 printf("light 4 is on\n\r");//Prof said to leave this is to prove our code works 00030 m.speed(0.5); 00031 } 00032 else if(sw3==1) { //toppings return 00033 lights=7; 00034 toppings=1.0; 00035 } 00036 else if(sw2==1) { //toppings dump 00037 lights=3; 00038 toppings=0.8; 00039 00040 } 00041 else if(sw1==1) { //clamp turns on 00042 lights=1; 00043 clamp=0.12; 00044 } 00045 else { 00046 lights=0; //no switches on = no lights, DC motor off 00047 m.speed(0.0); 00048 } 00049 00050 } 00051 }
Generated on Wed Jul 13 2022 05:29:33 by
1.7.2
