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.
Dependencies: mbed
main.cpp
- Committer:
- jiteshg
- Date:
- 2015-10-08
- Revision:
- 1:8c73948a0864
- Parent:
- 0:fd080fb55bae
- Child:
- 2:bf817b299c19
File content as of revision 1:8c73948a0864:
/* Using pwm to run a servo motor Connect the red wire of the servo motor to 3.3V and not 5V */ #include "mbed.h" PwmOut pwm1(p21); Serial pc(USBTX, USBRX); int main() { pwm1.period_ms(20); while(1){ char c = pc.getc(); if(c=='1'){ pwm1.write(0); wait(0.5); pwm1.write(0.0375); // 3.75% duty cycle - Open the gate } else{ pwm1.write(0); wait(0.5); pwm1.write(0.1125); // 11.25% duty cycle - Close the gate } } return 0; }