LED Pattern s

Dependencies:   mbed

Committer:
jont
Date:
Thu Mar 03 14:58:31 2016 +0000
Revision:
0:a8f171f6873d
first release

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jont 0:a8f171f6873d 1 #include "mbed.h"
jont 0:a8f171f6873d 2 /*
jont 0:a8f171f6873d 3 jont@ninelocks.com
jont 0:a8f171f6873d 4 Led Light Chaser for Schools demonstration
jont 0:a8f171f6873d 5
jont 0:a8f171f6873d 6 */
jont 0:a8f171f6873d 7 //replace the next line with the output from the designer program
jont 0:a8f171f6873d 8 char pattern[] = { 0x01,0x02,0x04,0x08,0x04,0x02,0x01,0x02,0x04,0x08,0x04,0x02,0x01,0x02,0x04,0x05};
jont 0:a8f171f6873d 9
jont 0:a8f171f6873d 10 //group LEDS as a unit
jont 0:a8f171f6873d 11 BusOut myleds(LED1, LED2, LED3, LED4);
jont 0:a8f171f6873d 12
jont 0:a8f171f6873d 13 //writes bytes to the display
jont 0:a8f171f6873d 14 void display_pattern(char *testdata){
jont 0:a8f171f6873d 15 //this finds how many elements in the array
jont 0:a8f171f6873d 16 int arraysize = sizeof(pattern)/sizeof(pattern[0]);
jont 0:a8f171f6873d 17 for(int idx = 0; idx < arraysize; idx++) {
jont 0:a8f171f6873d 18 myleds = testdata[idx];
jont 0:a8f171f6873d 19 wait(0.2);
jont 0:a8f171f6873d 20 }
jont 0:a8f171f6873d 21 }
jont 0:a8f171f6873d 22
jont 0:a8f171f6873d 23 int main() {
jont 0:a8f171f6873d 24 while(1) {
jont 0:a8f171f6873d 25 display_pattern(pattern);
jont 0:a8f171f6873d 26 wait(0.5);
jont 0:a8f171f6873d 27 }
jont 0:a8f171f6873d 28 }