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 /*Program Example 4.6: Software generated PWM. 2 PWM values generated in turn, with full on and off included for comparison. 00002 */ 00003 #include "mbed.h" 00004 DigitalOut motor(p6); 00005 int i; 00006 int main() 00007 { 00008 while(1) { 00009 motor = 0; //motor switched off for 5 secs 00010 wait (5); 00011 for (i=0; i<5000; i=i+1) { //5000 PWM cycles, low duty cycle 00012 motor = 1; 00013 wait_us(400); //output high for 400us 00014 motor = 0; 00015 wait_us(600); //output low for 600us 00016 } 00017 for (i=0; i<5000; i=i+1) { //5000 PWM cycles, high duty cycle 00018 motor = 1; 00019 wait_us(800); //output high for 800us 00020 motor = 0; 00021 wait_us(200); //output low for 200us 00022 } 00023 motor = 1; //motor switched fully on for 5 secs 00024 wait (5); 00025 } 00026 } 00027
Generated on Tue Aug 2 2022 00:09:34 by
1.7.2