Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 #include "mbed.h" 00002 00003 Serial pc(SERIAL_TX, SERIAL_RX); 00004 00005 AnalogIn p1(A0); // entrada analoga potenciometro x 00006 AnalogIn p2(A1);// entrada analoga potenciometro y 00007 AnalogIn boton(A2);// entrada analoga boton 00008 00009 float potx; //potenciometro en x 00010 float poty; // potenciometro en y 00011 float boton1; // boton 00012 00013 00014 DigitalOut led(LED1); 00015 00016 void leer(void); 00017 00018 int main() { 00019 pc.baud(9600); 00020 00021 while(1) 00022 { 00023 leer(); 00024 while(boton1==1)// espera hasta que se levante el boton 00025 { 00026 leer(); 00027 if(boton1==0) // espera hasta precionar el boton 00028 led=!led; // prende y apaga led 00029 } 00030 } 00031 } 00032 00033 00034 void leer() 00035 { 00036 potx = p1.read(); // Lee potenciometr0 x, valores entre 0.0 y 1.0 00037 pc.printf("%f ",potx); 00038 00039 00040 poty = p2.read(); // Lee potenciometro y, valores entre 0.0 y 1.0 00041 pc.printf(" %f ",poty); 00042 00043 boton1 = boton.read(); // Lee boton, valores entre 0.0 y 1.0 (valor<0.005 oprimido) 00044 pc.printf(" %f \n ",boton1); 00045 00046 if (boton1<0.005) // si el valor es mas pe queño que 0.005 esa presionado 00047 boton1=0; 00048 else 00049 boton1=1; 00050 00051 // wait(0.4); // si se quiere revisar valor leido por serial quietar comentario para q sea mas lento en el terminal 00052 00053 }
Generated on Sun Sep 18 2022 03:14:48 by
1.7.2