4 LED flashing program with LPC1114FN28. Easy configuration for : 1. Flash period 2. Flash polarity ( Actilve Low / High ) 3. Selectable number of LED, 2,3 or 4
Diff: main.cpp
- Revision:
- 0:4e264e403d13
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Apr 13 05:21:25 2014 +0000 @@ -0,0 +1,56 @@ +#include "mbed.h" + + /* Pin declaration for LED */ +DigitalOut led1(LED1); +DigitalOut led2(LED2); +DigitalOut led3(dp27); +DigitalOut led4(dp26); + +#define ACTIVELOW // Comment out if the LED driver input is Active High +#define CYCLE 0.5 // Duration of turning on for each LED in second +#define NUMLED 4 // How many LEDs do you have? + + +/* Dont change the lines below here */ + +#ifdef ACTIVELOW +#define LEDON 0 +#define LEDOFF 1 +#else +#define LEDON 1 +#define LEDOFF 0 +#endif /* ACTIVELOW */ + + +int main() { + + /* repeat forever */ + while(1) { + /* Turn on and off LED 1 */ + led1 = LEDON; + wait(CYCLE); + led1 = LEDOFF; + + /* Turn on and off LED 2 */ + led2 = LEDON; + wait(CYCLE); + led2 = LEDOFF; + + /* if only two LED, skip LED 3 and 4 */ +#if NUMLED <= 2 + continue; +#endif + /* Turn on and off LED 3 */ + led3 = LEDON; + wait(CYCLE); + led3 = LEDOFF; + + /* if only three LED, skip LED 4 */ +#if NUMLED <= 3 + continue; +#endif + /* Turn on and off LED 4 */ + led4 = LEDON; + wait(CYCLE); + led4 = LEDOFF; + }}