![](/media/cache/profiles/avatar_OHHPjmG.jpg.50x50_q85.jpg)
ON OFF LED
Revision 0:100c914c126b, committed 2018-05-26
- Comitter:
- RazielLopez
- Date:
- Sat May 26 14:51:59 2018 +0000
- Commit message:
- estable
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LED_COLORES/Led_Colores.cpp Sat May 26 14:51:59 2018 +0000 @@ -0,0 +1,23 @@ +#include "mbed.h" +#include "Led_Colores.h" + +DigitalOut ledR(LED_RED); +DigitalOut ledB(LED_BLUE); +DigitalOut ledG(LED_GREEN); + +void ColorLed(int c){ + + + if(c & BIT_RED ) + ledR=on; + else + ledR= off; + if(c & BIT_GREEN) + ledG=on; + else + ledG=off; + if(c & BIT_BLUE) + ledB=on; + else + ledB=off; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LED_COLORES/Led_Colores.h Sat May 26 14:51:59 2018 +0000 @@ -0,0 +1,12 @@ +#include "mbed.h" +#define off 1 +#define on 0 + +void ColorLed(int); + +enum Bit_Color{ + BIT_RED=1,BIT_GREEN=2,BIT_BLUE=4 + }; +enum Led_Color { + BLACK,RED,GREEN,YELLOW,BLUE,MAGENTA,CYAN,WHITE + }; \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat May 26 14:51:59 2018 +0000 @@ -0,0 +1,24 @@ +#include "mbed.h" +#include "Led_Colores.h" + +DigitalIn sw3(SW3); //Declaramos switch 2 +DigitalIn sw2(SW2); //Declaramos switch3 + +int main() +{ + ColorLed(BLACK); + int bandera=0; + while (true) { + if(!sw2 && sw3){ //sw2 se niega porque al apretarlo regresa un 0 + ColorLed(RED); //Prende LED rojo + } + else if(!sw3 && sw2){ //sw3 se niega porque al apretarlo regresa un 0 + ColorLed(BLACK); //Prende LED Azul + wait(1.0f); + ColorLed(GREEN); + } + + + wait(0.2f); + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat May 26 14:51:59 2018 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9327015d4013 \ No newline at end of file