Write a variable into a led bus

Dependencies:   Hotboards_leds mbed

Fork of leds by Roman Valencia

Committer:
RomanValenciaP
Date:
Mon Feb 29 20:00:08 2016 +0000
Revision:
0:2f277fc001e3
leds

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RomanValenciaP 0:2f277fc001e3 1
RomanValenciaP 0:2f277fc001e3 2 /*
RomanValenciaP 0:2f277fc001e3 3 * Write a variable into a led bus
RomanValenciaP 0:2f277fc001e3 4 *
RomanValenciaP 0:2f277fc001e3 5 * Connections:
RomanValenciaP 0:2f277fc001e3 6 *
RomanValenciaP 0:2f277fc001e3 7 * PA_5 --- led0
RomanValenciaP 0:2f277fc001e3 8 * PA_6 --- led1
RomanValenciaP 0:2f277fc001e3 9 * PA_7 --- led2
RomanValenciaP 0:2f277fc001e3 10 * PB_6 --- led3
RomanValenciaP 0:2f277fc001e3 11 * PC_7 --- led4
RomanValenciaP 0:2f277fc001e3 12 * PA_9 --- led5
RomanValenciaP 0:2f277fc001e3 13 * PA_8 --- led6
RomanValenciaP 0:2f277fc001e3 14 * PB_10 --- led8
RomanValenciaP 0:2f277fc001e3 15 *
RomanValenciaP 0:2f277fc001e3 16 */
RomanValenciaP 0:2f277fc001e3 17
RomanValenciaP 0:2f277fc001e3 18 #include "mbed.h"
RomanValenciaP 0:2f277fc001e3 19 #include "Hotboards_leds.h"
RomanValenciaP 0:2f277fc001e3 20
RomanValenciaP 0:2f277fc001e3 21 //Creates a bus with 8 leds
RomanValenciaP 0:2f277fc001e3 22 // bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
RomanValenciaP 0:2f277fc001e3 23 Hotboards_leds leds( PB_10 , PA_8 , PA_9 , PC_7 , PB_6 , PA_7 , PA_6 , PA_5 );
RomanValenciaP 0:2f277fc001e3 24
RomanValenciaP 0:2f277fc001e3 25 uint8_t counter;
RomanValenciaP 0:2f277fc001e3 26
RomanValenciaP 0:2f277fc001e3 27 int main()
RomanValenciaP 0:2f277fc001e3 28 {
RomanValenciaP 0:2f277fc001e3 29 counter = 0;
RomanValenciaP 0:2f277fc001e3 30 while(1)
RomanValenciaP 0:2f277fc001e3 31 {
RomanValenciaP 0:2f277fc001e3 32 //Shows on the led bus the counter variable value
RomanValenciaP 0:2f277fc001e3 33 leds.write( counter );
RomanValenciaP 0:2f277fc001e3 34 wait_ms( 500 );
RomanValenciaP 0:2f277fc001e3 35 counter ++;
RomanValenciaP 0:2f277fc001e3 36 //We can still manipulate each led individually with
RomanValenciaP 0:2f277fc001e3 37 //the functions turnOn, turnOff, toggle, write, but in
RomanValenciaP 0:2f277fc001e3 38 //this case the function will need a parameter indicating
RomanValenciaP 0:2f277fc001e3 39 //the led you want to manipulate
RomanValenciaP 0:2f277fc001e3 40 //Example: leds.turnOn(3) turns ON led #3
RomanValenciaP 0:2f277fc001e3 41 }
RomanValenciaP 0:2f277fc001e3 42 }