Joseanne Viana
/
projeto_final_v2
implementação da entrada analogica
Fork of projeto_final by
Diff: main.cpp
- Revision:
- 1:57ddb7333156
- Parent:
- 0:14a3f9fb0c13
diff -r 14a3f9fb0c13 -r 57ddb7333156 main.cpp --- a/main.cpp Mon May 16 23:09:27 2016 +0000 +++ b/main.cpp Thu May 19 00:31:15 2016 +0000 @@ -2,6 +2,9 @@ int main(void) { Serial pc(USBTX, USBRX); + AnalogIn ain(A0); + DigitalOut ligaMaisPilha(PTA17); + DigitalOut ligaMaisLed(PTA16); PwmOut rled(LED1); PwmOut gled(LED2); PwmOut bled(LED3); @@ -10,10 +13,23 @@ rled=1.0f; gled=1.0f; bled=1.0f; + int x; + + while(true){ if(pc.readable()) { msg = pc.getc(); num = pc.getc(); + + x=ain.read(); + if(x < 0.4){//equivale a 3.31V + ligaMaisPilha=0; + ligaMaisLed =0; + } + else { + ligaMaisPilha=1; + ligaMaisLed= 1; + }//else switch(msg){ case 'R': //brilho rled = 1.0f - float(num)/255.0;