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 18:01:50 2014 +0000
Revision:
0:c1e6182f8ed6
ver 1.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
4180_1 0:c1e6182f8ed6 1 #include "mbed.h"
4180_1 0:c1e6182f8ed6 2 //LED Tower Strobe Light Effect
4180_1 0:c1e6182f8ed6 3 //
4180_1 0:c1e6182f8ed6 4 BusOut myleds(LED1, LED2, LED3, LED4);
4180_1 0:c1e6182f8ed6 5 //groups 4 built-in LEDs digital outputs together
4180_1 0:c1e6182f8ed6 6 //on mbed LPC1768 - change pins for other platforms
4180_1 0:c1e6182f8ed6 7 int main()
4180_1 0:c1e6182f8ed6 8 {
4180_1 0:c1e6182f8ed6 9 while(1) {
4180_1 0:c1e6182f8ed6 10 int j=1; //one LED on at start of loop
4180_1 0:c1e6182f8ed6 11 for(int i=1; i<16; i++) {
4180_1 0:c1e6182f8ed6 12 //sends out digital values for all LEDs (0 or 1)
4180_1 0:c1e6182f8ed6 13 myleds = j;
4180_1 0:c1e6182f8ed6 14 //binary shift the 1-bit (1=LED on) left by one
4180_1 0:c1e6182f8ed6 15 j = j<<1;
4180_1 0:c1e6182f8ed6 16 //use wait to add a time delay close to a real tower light
4180_1 0:c1e6182f8ed6 17 wait(0.093);
4180_1 0:c1e6182f8ed6 18 }
4180_1 0:c1e6182f8ed6 19 }
4180_1 0:c1e6182f8ed6 20 }
4180_1 0:c1e6182f8ed6 21