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.
servo.cpp
00001 #include "servo.h" 00002 PwmOut servo(p21); 00003 00004 void setServo(){ 00005 servo.pulsewidth_us(1500); 00006 wait(2); 00007 } 00008 00009 void moveServo(char a){ 00010 switch(a){ 00011 case 1: servo.pulsewidth_us(pulsewidth(-90)); break; 00012 case 2: servo.pulsewidth_us(pulsewidth(-67.5)); break; 00013 case 3: servo.pulsewidth_us(pulsewidth(-45)); break; 00014 case 4: servo.pulsewidth_us(pulsewidth(-22.5)); break; 00015 case 5: servo.pulsewidth_us(pulsewidth(0)); break; 00016 case 6: servo.pulsewidth_us(pulsewidth(22.5)); break; 00017 case 7: servo.pulsewidth_us(pulsewidth(45)); break; 00018 case 8: servo.pulsewidth_us(pulsewidth(67.5)); break; 00019 case 9: servo.pulsewidth_us(pulsewidth(90)); break; 00020 } 00021 00022 } 00023 00024 int pulsewidth(int a){ 00025 return 1500 + 10*a; 00026 }
Generated on Tue Jul 12 2022 15:06:42 by
1.7.2