Cálculo por terminal. Test.

Dependencies:   ADC

Dependents:   ADC

Revision:
107:5c6c2ba54077
Parent:
105:ed03c03b353e
Child:
108:5a5126fe974e
--- a/main.cpp	Fri Nov 22 16:00:04 2019 +0000
+++ b/main.cpp	Mon Dec 09 12:05:29 2019 +0000
@@ -3,21 +3,33 @@
  * SPDX-License-Identifier: Apache-2.0
  */
 
-#include "mbed.h"
-#include "platform/mbed_thread.h"
+#include<mbed.h>
 
 
-// Blinking rate in milliseconds
-#define BLINKING_RATE_MS                                                    500
-
+AnalogIn signal(GPIO0);
+Serial pc(USBTX, USBRX);
+Timer timer;
 
 int main()
 {
-    // Initialise the digital pin LED1 as an output
-    DigitalOut led(LED1);
-
+    //Declaro las variables
+    float Tension = 0;
+    unsigned short adcValor;
+    long previousTime = 0;
+    long currentTime = 0;
+    pc.baud(9600); //Baudrate
+    timer.start();   
+    
     while (true) {
-        led = !led;
-        thread_sleep_for(BLINKING_RATE_MS);
+        currentTime = timer.read_ms();
+        if(currentTime - previousTime >= 1000){
+        
+            adcValor = signal.read_u16();
+            float flotante = signal.read();
+            //Tension = (adcValor * 3.3/255); // Lo paso a valor de tension
+        
+            pc.printf("El valor del ADC %i y leido directo %.2f \r\n", adcValor, flotante); // Imprimo en terminal
+            previousTime = currentTime;
+        }
     }
 }