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 /* sample for dimming led with pwm. 00002 * Copyright (c) 2015 Match 00003 */ 00004 00005 #include "mbed.h" 00006 00007 // F401, F411 can use LED1. 00008 // Other platform, use pwm pin and connect led. 00009 PwmOut myled(LED1); 00010 00011 int main() { 00012 int duty = 0; // unit:% 00013 myled.period_ms(1); // pwm frequency set 1kHz. 00014 00015 while(1) { 00016 // until 100%, increase by 5% in 50ms intervals 00017 for (; duty <= 100; duty += 5) { 00018 myled = duty / 100.0; 00019 wait_ms(50); 00020 } 00021 // until 0%, decrease by 5% in 50ms intervals 00022 for (; duty >= 0; duty -= 5) { 00023 myled = duty / 100.0; 00024 wait_ms(50); 00025 } 00026 } 00027 }
Generated on Wed Jul 27 2022 23:04:51 by
1.7.2