Sistemes_Encastats_2016 / Mbed OS Practica_1

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Files at this revision

API Documentation at this revision

Comitter:
dukus265
Date:
Fri Sep 23 15:24:07 2016 +0000
Parent:
12:f4cb0404a9a2
Commit message:
Practica_1;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Fri Sep 16 19:00:07 2016 +0100
+++ b/main.cpp	Fri Sep 23 15:24:07 2016 +0000
@@ -1,13 +1,38 @@
 #include "mbed.h"
 
-DigitalOut led1(LED1);
-
-// main() runs in its own thread in the OS
-// (note the calls to Thread::wait below for delays)
+DigitalOut led2(LED2);
+DigitalOut led3(LED3);
+DigitalIn  pol1(USER_BUTTON);
+AnalogIn analog_value(A0);
+DigitalOut Pullup(A5);
+ 
+//------------------------------------
+// Hyperterminal configuration
+// 9600 bauds, 8-bit data, no parity
+//------------------------------------
+ 
+Serial pc(SERIAL_TX, SERIAL_RX);
+ 
+DigitalOut myled(LED1);
+ 
 int main() {
-    while (true) {
-        led1 = !led1;
-        Thread::wait(500);
+  Pullup = true;
+  float Valor = 0;
+  
+pc.printf("Apreta el polsador quan hagis regulat el potenciometre !\n");
+while(1){
+    
+    while(pol1==1){
     }
+    while(pol1==0){
+        Valor = analog_value.read(); // llegeix el valor de la entrada analogica A0
+        Valor = Valor*5;
+        pc.printf("%f\n", Valor);
+        myled = !myled; 
+    while(pol1==0){
+        }  
+  }
+  
 }
+}