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

Committer:
4180_1
Date:
Fri Nov 28 17:55:51 2014 +0000
Revision:
0:4f30d6d9f970
ver 1.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
4180_1 0:4f30d6d9f970 1 #include "mbed.h"
4180_1 0:4f30d6d9f970 2 //LED Warning Beacon Lighting Effect
4180_1 0:4f30d6d9f970 3 PwmOut myled(LED2);
4180_1 0:4f30d6d9f970 4 //Use a PWM output to enable dimming
4180_1 0:4f30d6d9f970 5 //1.0 is full on, 0.0 off, 0.5 50% on
4180_1 0:4f30d6d9f970 6 int main()
4180_1 0:4f30d6d9f970 7 {
4180_1 0:4f30d6d9f970 8 while(1) {
4180_1 0:4f30d6d9f970 9 //LED warm up effect using PWM
4180_1 0:4f30d6d9f970 10 for(int i=0; i<50; i++) {
4180_1 0:4f30d6d9f970 11 myled = i/50.0;
4180_1 0:4f30d6d9f970 12 wait(0.02);
4180_1 0:4f30d6d9f970 13 }
4180_1 0:4f30d6d9f970 14 //LED at full brightness level
4180_1 0:4f30d6d9f970 15 myled = 1.0;
4180_1 0:4f30d6d9f970 16 wait(0.25);
4180_1 0:4f30d6d9f970 17 //LED cool down effect using PWM
4180_1 0:4f30d6d9f970 18 for(int i=49; i>0; i--) {
4180_1 0:4f30d6d9f970 19 myled = i/50.0;
4180_1 0:4f30d6d9f970 20 wait(0.02);
4180_1 0:4f30d6d9f970 21 }
4180_1 0:4f30d6d9f970 22 //LED off
4180_1 0:4f30d6d9f970 23 myled = 0.0;
4180_1 0:4f30d6d9f970 24 wait(1.5);
4180_1 0:4f30d6d9f970 25 }
4180_1 0:4f30d6d9f970 26 }