/*############################################################# Program Name : ex1_PWM_ramp_up Author : Grant Phillips Date Modified : 13/01/2016 Compiler : ARMmbed Tested On : STM32F4-Discovery Description : Example program that demonstrates the use of an PWM output. The output will be connected to an LED and the duty cycle will change from 0%, 25%, 50%, 75% and 100% every 2 seconds. Requirements : * STM32F4-Discovery Board Circuit : * An LED connected to PB5 * Connect PB5 to an oscilloscope to observe the effect of an PWM output graphically ##############################################################*/ #include "mbed.h" PwmOut myled(PB_5); int main() { while(1) { myled = 0.0; //set duty cycle to 0% wait(2.0); //wait 2 seconds myled = 0.25; //set duty cycle to 25% wait(2.0); myled = 0.50; //set duty cycle to 50% wait(2.0); myled = 0.75; //set duty cycle to 75% wait(2.0); myled = 1.0; //set duty cycle to 100% wait(2.0); } }