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.
Revision 0:050768391650, committed 2019-04-15
- Comitter:
- Mateom0104
- Date:
- Mon Apr 15 05:59:01 2019 +0000
- Commit message:
- control
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 Mon Apr 15 05:59:01 2019 +0000 @@ -0,0 +1,53 @@ +#include "mbed.h" + +Serial pc(SERIAL_TX, SERIAL_RX); + +AnalogIn p1(A0); // entrada analoga potenciometro x +AnalogIn p2(A1);// entrada analoga potenciometro y +AnalogIn boton(A2);// entrada analoga boton + +float potx; //potenciometro en x +float poty; // potenciometro en y +float boton1; // boton + + +DigitalOut led(LED1); + +void leer(void); + +int main() { + pc.baud(9600); + + while(1) + { + leer(); + while(boton1==1)// espera hasta que se levante el boton + { + leer(); + if(boton1==0) // espera hasta precionar el boton + led=!led; // prende y apaga led + } + } +} + + +void leer() +{ + potx = p1.read(); // Lee potenciometr0 x, valores entre 0.0 y 1.0 + pc.printf("%f ",potx); + + + poty = p2.read(); // Lee potenciometro y, valores entre 0.0 y 1.0 + pc.printf(" %f ",poty); + + boton1 = boton.read(); // Lee boton, valores entre 0.0 y 1.0 (valor<0.005 oprimido) + pc.printf(" %f \n ",boton1); + + if (boton1<0.005) // si el valor es mas pe queño que 0.005 esa presionado + boton1=0; + else + boton1=1; + + // wait(0.4); // si se quiere revisar valor leido por serial quietar comentario para q sea mas lento en el terminal + +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Apr 15 05:59:01 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file