Sistemes_Encastats_2016 / Mbed OS Practica_1

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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 DigitalOut led2(LED2);
00004 DigitalOut led3(LED3);
00005 DigitalIn  pol1(USER_BUTTON);
00006 AnalogIn analog_value(A0);
00007 DigitalOut Pullup(A5);
00008  
00009 //------------------------------------
00010 // Hyperterminal configuration
00011 // 9600 bauds, 8-bit data, no parity
00012 //------------------------------------
00013  
00014 Serial pc(SERIAL_TX, SERIAL_RX);
00015  
00016 DigitalOut myled(LED1);
00017  
00018 int main() {
00019   Pullup = true;
00020   float Valor = 0;
00021   
00022 pc.printf("Apreta el polsador quan hagis regulat el potenciometre !\n");
00023 while(1){
00024     
00025     while(pol1==1){
00026     }
00027     while(pol1==0){
00028         Valor = analog_value.read(); // llegeix el valor de la entrada analogica A0
00029         Valor = Valor*5;
00030         pc.printf("%f\n", Valor);
00031         myled = !myled; 
00032     while(pol1==0){
00033         }  
00034   }
00035   
00036 }
00037 }   
00038