Sistemes_Encastats_2016 / Mbed 2 deprecated Practica_Final_1

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
dukus265
Date:
Thu Sep 29 08:05:47 2016 +0000
Commit message:
Codi final

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 Sep 29 08:05:47 2016 +0000
@@ -0,0 +1,76 @@
+// Tutor: Ramon Reig Bolaño                             //
+// Alumnes:Jordi Duocastella, Albert Muñoz i David Yabar//
+//------------------------------------------------------//
+
+
+#include "mbed.h"
+
+DigitalOut led2(LED2);
+DigitalOut led3(LED3);
+DigitalOut buzzer(A1);
+DigitalIn  pol1(USER_BUTTON);
+AnalogIn analog_value(A0);
+DigitalOut pullup(A5);
+ 
+ 
+Serial pc(SERIAL_TX, SERIAL_RX);
+ 
+DigitalOut myled(LED1);
+ 
+int main() {
+  
+    float valor;
+    pullup = true;
+    char TAULA[0];  
+    led2 = 0;
+    valor = 0;
+  
+    pc.printf("\n\n\nGira el potenciometre i prem el boto blau per rebre un valor\n\n\r");
+    
+    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("%1.2f V \r\n", valor);
+            
+            buzzer = 1;
+            led2 = 1;
+            wait(0.1);
+            buzzer = 0;
+            led2 = 0;
+
+            while(pol1==0){;}
+        
+    }            
+    if((valor>=0)and (valor<=1.25)){
+         TAULA[0]='H';
+         pc.printf("H \r\n", valor);
+         }
+    if((valor>=1.26)and (valor<=2.50)){
+         TAULA[1]='O';
+         pc.printf("O \r\n", valor);
+         }
+    if((valor>=2.51)and (valor<=3.75)){
+         TAULA[2]='L';
+         pc.printf("L \r\n", valor);
+         }
+    if((valor>=3.76)and (valor<=5)){
+         TAULA[3]='A';
+         pc.printf("A \r\n", valor);
+         }
+    if((TAULA[0]=='H')and(TAULA[1]=='O')and(TAULA[2]=='L')and(TAULA[3]=='A')){
+        while(1){
+        pc.printf("HOLA MON!!!!! \r\n");
+        buzzer = 1;
+        led2 = 1;
+        wait(0.1);
+        led2 = 0;
+        buzzer = 0;
+        wait(0.1);
+        }
+        }
+}
+}  
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Sep 29 08:05:47 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/abea610beb85
\ No newline at end of file