implementação da entrada analogica

Dependencies:   mbed

Fork of projeto_final by Guilherme Paulino

Files at this revision

API Documentation at this revision

Comitter:
Josiii
Date:
Thu May 19 00:31:15 2016 +0000
Parent:
0:14a3f9fb0c13
Commit message:
coloquei a entrada analogica

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- 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;