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 Rejestrator
WaitForSwitch.cpp
00001 #include "WaitForSwitch.h" 00002 00003 void WaitForSwitch(DigitalIn Switch, PwmOut led) 00004 { 00005 float Pwm = 0; 00006 while (Switch.read() != 0) 00007 { 00008 led = Pwm; 00009 Pwm += 0.01; 00010 if (Pwm > 1) Pwm = 0; 00011 rtos::Thread::wait(10); 00012 } 00013 while (Switch.read() == 0) 00014 { 00015 led = Pwm; 00016 Pwm -= 0.01; 00017 if (Pwm < 0) Pwm = 1; 00018 rtos::Thread::wait(10); 00019 } 00020 led = 0; 00021 }
Generated on Sat Jul 30 2022 15:40:24 by
