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 //================================================== 00002 //Servo 00003 // 00004 //MPU board: mbed LPC1768 00005 //2019/11/17 A.Toda 00006 //================================================== 00007 #include "mbed.h" 00008 00009 //================================================== 00010 #define SERVO_PERIOD 0.020 00011 //================================================== 00012 00013 //Port Setting 00014 00015 PwmOut ELE(p21); 00016 Serial pc(USBTX, USBRX); //UART 00017 00018 //================================================== 00019 //Timer valiables 00020 //================================================== 00021 00022 double pulse_width_ele; 00023 00024 //================================================== 00025 //Main 00026 //================================================== 00027 int main() { 00028 00029 //UART initialization 00030 pc.baud(115200); 00031 00032 //define servo period 00033 ELE.period(SERVO_PERIOD); // servo requires 20ms period 00034 pulse_width_ele=0.6/1000.0; 00035 00036 //while 00037 while(1) { 00038 00039 // servo position determined by a pulsewidth between 0.6-2.4ms 00040 00041 for(int i=0;i<18;i++){ 00042 pulse_width_ele += ( 0.1/1000.0 ); 00043 ELE.pulsewidth(pulse_width_ele); 00044 pc.printf("Pulse width is %f\r\n",pulse_width_ele); 00045 wait(1.0); 00046 } 00047 00048 pulse_width_ele=0.6/1000.0; 00049 00050 }//while ends 00051 00052 }//main ends
Generated on Wed Sep 21 2022 12:42:40 by
1.7.2