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 // dimmed kitt LED blinking 00002 // the question was how to enable dimming on multiple digital led the same time. 00003 // it could be done simpler with math/sin, yet it I found it more fun 00004 #include "mbed.h" 00005 #include "math.h" 00006 00007 PwmOut led[4] = { LED1, LED2, LED3, LED4 }; 00008 00009 float DimVal( int idx, float f ) { 00010 return (sin(f + float(idx)*1.6) + 1.0) / 2.0; // transform value from -1.0 .. 1.0 to 0.0 .. 1.0 00011 } 00012 00013 int main() { 00014 while (1) { 00015 for (float f = 0.0f; f < 6.3; f += 0.1f) { 00016 led[0] = DimVal( 0, f ); 00017 led[1] = DimVal( 1, f ); 00018 led[2] = DimVal( 2, f ); 00019 led[3] = DimVal( 3, f ); 00020 wait_ms(10); 00021 } 00022 } 00023 }
Generated on Fri Jul 22 2022 22:14:20 by
