Multímetro

Dependencies:   mbed LCDLib

Files at this revision

API Documentation at this revision

Comitter:
meksc
Date:
Thu Jul 04 12:24:39 2019 +0000
Parent:
1:808bed0f2433
Commit message:
projeto arlindo

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 808bed0f2433 -r fb35f75110ee main.cpp
--- a/main.cpp	Thu Jun 27 12:44:36 2019 +0000
+++ b/main.cpp	Thu Jul 04 12:24:39 2019 +0000
@@ -2,12 +2,14 @@
 #include "TextLCD.h"
 
 
+
 DigitalOut led1(PC_13);
 TextLCD lcd(PA_4,PA_5,PA_6,PB_12,PB_13,PB_14,PB_15);
 AnalogIn adc(PA_0);
 AnalogIn tensaofixa(PA_1);
+Serial pc(PA_9, PA_10);// ver qual porta e rx e tx
 
-InterruptIn botao(PA_7);
+/*InterruptIn botao(PA_7);
 volatile bool botao_pressed = false; // Used in the main loop
 volatile bool botao_enabled = true; // Used for debouncing
 Timeout botao_timeout; // Used for debouncing
@@ -27,15 +29,15 @@
         botao_timeout.attach(callback(botao_enabled_cb), 0.3); // Debounce time 300 ms
     }
 }
-
+*/
 
 int main()
 {
     float alim, tensao, corrente, resistencia;
-    int cont;
-    cont = 1;
+    char cont;
+    cont = '1';
     //button1.mode(PullUp); // Activate pull-up
-    botao.fall(callback(botao_onpressed_cb)); // Attach ISR to handle button press event
+    //botao.fall(callback(botao_onpressed_cb)); // Attach ISR to handle button press event
 
     while(1) {
         
@@ -43,8 +45,10 @@
         tensao = 3.3*adc.read();
         resistencia = (tensao*1000)/(alim-tensao);
         corrente = (tensao/resistencia) * 1000;
+        cont= pc.getc ();
         
-        if (botao_pressed == true) { // Set when button is pressed
+        
+       /* if (botao_pressed == true) { // Set when button is pressed
             botao_pressed = false;
             cont = cont++;        
             led1 = !led1;
@@ -52,20 +56,23 @@
         if(cont == 4){
             cont = 1;    
         }
-        if(cont == 1){
-            lcd.gotoxy(1,1);
-            lcd.printf("Tensao: %.2fV       ",tensao);
+        */
+        
+        if(cont == '1'){
+           //lcd.gotoxy(1,1);
+            //lcd.printf("Tensao: %.2fV       ",tensao);
+            pc.printf("Tensao: %.2fV       ",tensao);
             wait(0.2);
             
         }
-        if(cont == 2){
-            lcd.gotoxy(1,1);
-            lcd.printf("Corrente: %.2fmA       ",corrente);
+        if(cont == '2'){
+            //lcd.gotoxy(1,1);
+            pc.printf("Corrente: %.2fmA       ",corrente);
             wait(0.2);
         }
-        if(cont == 3){
-            lcd.gotoxy(1,1);
-            lcd.printf("Res.:% .0fohm     ",resistencia);
+        if(cont == '3'){
+            //lcd.gotoxy(1,1);
+            pc.printf("Res.:% .0fohm     ",resistencia);
             wait(0.2);
         }