Demo of LED lighting effects using PWM and wait for time delays. Pins are setup for LPC1768 platform’s LEDs. For complete information, see http://developer.mbed.org/users/4180_1/notebook/led-lighting-effects-for-modelers/

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 //LED Lighthouse or Searchlight lighting effect
00003 PwmOut myled(LED1);
00004 //use Pwm output for dimming
00005 
00006 int main()
00007 {
00008     float y=0.0;
00009     while(1) {
00010         for(double x=0.0; x <= 3.14159; x = x + 0.0314159) {
00011             y = sin(x); //nice periodic function 0..1..0
00012             myled = y*y*y;//exponential effect - needs a sharp peak
00013             wait(.025);
00014         }
00015         myled = 0.0;
00016         //most lighthouses have a 5 second delay - so add another 2.5
00017         wait(2.5);
00018     }
00019 }