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 by
main.cpp
00001 #include "mbed.h" 00002 #include "Servo.h" 00003 #include "Motor.h" 00004 00005 Servo myservo(p21); 00006 Servo myservo2(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,p10,p11); 00010 00011 00012 int main() 00013 { 00014 while(1) 00015 { 00016 wait(0.5); 00017 if(sw5==1) { //servo1 off 00018 lights=31; 00019 printf("light 5 is on\n\r"); 00020 } 00021 else if(sw4==1) { //dc motor off 00022 lights=15; 00023 printf("light 4 is on\n\r"); 00024 m.speed(0.0); 00025 } 00026 else if(sw3==1) { //servo2 on 00027 lights=7; 00028 printf("light 3 is on\n\r"); 00029 } 00030 else if(sw2==1) { //dc motor on 00031 lights=3; 00032 printf("light 2 is on\n\r"); 00033 m.speed(1.0); 00034 } 00035 else if(sw1==1) { //servo1 comes on 00036 lights=1; 00037 printf("light 1 is on\n\r"); 00038 } 00039 else { 00040 lights=0; //no switches on = no lights or motors on 00041 m.speed(0.0);} 00042 00043 } 00044 }
Generated on Fri Jul 15 2022 11:05:23 by
1.7.2
