Guilherme Ferreira
/
acender_botoes
Turn on and off RGB Led with the 5 buttons.
main.cpp
- Committer:
- guilferr
- Date:
- 2018-09-14
- Revision:
- 0:3a0fab19df23
File content as of revision 0:3a0fab19df23:
#include "mbed.h" DigitalIn b1(D12); DigitalIn b2(D11); DigitalIn b3(D10); DigitalIn b4(D9); DigitalIn b5(D8); PwmOut vr(LED_RED); PwmOut vd(LED_GREEN); PwmOut az(LED_BLUE); int main() { vr=1; vd=1; az=1; int contb2=0,contb3=0,contb4=0; while(1) { int stat; if(!b5){ stat=1; wait_ms(100); }else{ stat=0; wait_ms(100); } if(stat){ vr=1; vd=1; az=1; wait_ms(100); }else{ if(!b1){ vr=0; vd=0; az=0; wait_ms(100); } if(!b2){ vr=0; contb2++; wait_ms(100); } if(contb2==2){ contb2=0; vr=1; wait_ms(100); } if(!b3){ vd=0; contb3++; wait_ms(100); } if(contb3==2){ contb3=0; vd=1; wait_ms(100); } if(!b4){ az=0; contb4++; wait_ms(100); } if(contb4==2){ contb4=0; az=1; wait_ms(100); } } } }