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:58:39 2014 +0000
Revision:
0:71618f1cfb5f
ver 1.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
4180_1 0:71618f1cfb5f 1 #include "mbed.h"
4180_1 0:71618f1cfb5f 2 //LED emergency vehicle lighting effect
4180_1 0:71618f1cfb5f 3 PwmOut myled(LED1);
4180_1 0:71618f1cfb5f 4 PwmOut myled2(LED4);
4180_1 0:71618f1cfb5f 5 //Use PWM for dimming
4180_1 0:71618f1cfb5f 6
4180_1 0:71618f1cfb5f 7 int main()
4180_1 0:71618f1cfb5f 8 {
4180_1 0:71618f1cfb5f 9 while(1) {
4180_1 0:71618f1cfb5f 10 //flash three times on LED1
4180_1 0:71618f1cfb5f 11 for(int i=0; i<3; i++) {
4180_1 0:71618f1cfb5f 12 //ramp up brightness level
4180_1 0:71618f1cfb5f 13 for(double x = 0.0; x <= 1.0; x = x+0.2) {
4180_1 0:71618f1cfb5f 14 myled = x*x;
4180_1 0:71618f1cfb5f 15 wait(.02);
4180_1 0:71618f1cfb5f 16 }
4180_1 0:71618f1cfb5f 17 }
4180_1 0:71618f1cfb5f 18 myled=0.0; //LED1 off
4180_1 0:71618f1cfb5f 19 //flash three times on LED2
4180_1 0:71618f1cfb5f 20 for(int i=0; i<3; i++) {
4180_1 0:71618f1cfb5f 21 //ramp up brightness level
4180_1 0:71618f1cfb5f 22 for(double x = 0.0; x <= 1.0; x = x+0.2) {
4180_1 0:71618f1cfb5f 23 myled2 = x*x;
4180_1 0:71618f1cfb5f 24 wait(.02);
4180_1 0:71618f1cfb5f 25 }
4180_1 0:71618f1cfb5f 26 }
4180_1 0:71618f1cfb5f 27 myled2=0.0; //LED2 off
4180_1 0:71618f1cfb5f 28 }
4180_1 0:71618f1cfb5f 29 }