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.
main.cpp
00001 #include "mbed.h" 00002 #define MAXPOS 50 00003 #define SS_TIME 100 00004 00005 PwmOut myServoX(PB_3); 00006 PwmOut myServoY(PB_4); 00007 00008 00009 00010 void vertex2d(float x, float y){ 00011 00012 int pulseX =x*2000/50+500 ; 00013 int pulseY =y*2000/50+500 ; 00014 00015 00016 00017 00018 00019 myServoX.pulsewidth_us(pulseX); 00020 myServoY.pulsewidth_us(pulseY); 00021 wait_ms(SS_TIME); 00022 00023 } 00024 00025 00026 int main() { 00027 00028 myServoX.period_ms(20); 00029 myServoY.period_ms(20); 00030 int posx=0; 00031 int posy=0; 00032 while(1) 00033 { 00034 wait(2); 00035 vertex2d(posx,posy); 00036 posx+=10; 00037 posy+=10; 00038 if (posx>50) posx=0; 00039 if (posy>50) posy=0; 00040 00041 00042 } 00043 00044 } 00045
Generated on Sat Jul 23 2022 07:57:59 by
