DEBER2

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
davidcarpioc
Date:
Thu Jan 17 23:22:20 2019 +0000
Commit message:
DCARPIOH

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jan 17 23:22:20 2019 +0000
@@ -0,0 +1,29 @@
+#include "mbed.h"
+#include <stdio.h>
+Serial device(PA_2,PA_3);
+AnalogIn sensor(PC_1);
+DigitalOut led1(PB_2);
+DigitalOut led2(PB_3);
+
+float dato,total;
+int muestras,tiempo,promedio;
+int valor[99];
+int main() {
+    device.baud(19200);
+    led1=0;
+    led2=0;
+    dato=0;
+    while(1) {
+        device.printf("\nINGRESE # DE MUESTRAS:");
+        device.scanf("%d[^\n]",muestras);
+        device.printf("\nINGRESE EL TIEMPO ENTRE MUESTRAS:");
+        device.scanf("%d[^\n]",tiempo);
+            for(int x=1;x>=muestras;x=x+1)
+            {valor[x]=sensor.read();
+            dato=dato+valor[x]; 
+            device.printf("\nMUESTRA #:%d =%d",x,muestras);
+            wait(tiempo);}
+            total=dato/muestras; 
+            device.printf("\nPromedio:%d",total);   
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Jan 17 23:22:20 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc
\ No newline at end of file