Lectura de valor analògic. Versió 1.0
Fork of mbed-os-example-mbed5-blinky by
main.cpp
- Committer:
- dukus265
- Date:
- 2016-09-23
- Revision:
- 13:97ab7efd29ac
- Parent:
- 8:bb09890333fe
File content as of revision 13:97ab7efd29ac:
#include "mbed.h"
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() {
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){
}
}
}
}
