![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
lllllservo
Diff: main.cpp
- Revision:
- 0:dd86afd987d0
diff -r 000000000000 -r dd86afd987d0 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Nov 19 22:31:26 2017 +0000 @@ -0,0 +1,82 @@ +#include "mbed.h" + +AnalogIn voltaje(PTB0); +Serial jd(USBTX, USBRX); +DigitalOut led(LED1); +DigitalIn p(PTC5); +DigitalOut m(PTC6); +DigitalIn l(PTC3); +DigitalOut h(PTC0); +float v; +int j=0; +int t; +int x=0; +int main(){ + while(1){ + v=voltaje.read()*3.3; + int t=(int)v;//cambiar de flotante a un entero + + + if(l==1){ + + j=1; + led=0; + m=1; + wait(1); + //wait(10); + + + } + + else{ + led=1; + m=0; + j=0; + //wait(2); + } + switch(j){ + case 1: + if(j==t){ + m=0; + led=1; + jd.printf("azul\n"); + wait(5); + h=1; + wait(5); + h=0; + + + } + break;} + + //aparte + if(p==1){ + + j=2; + led=0; + m=1; + + } + + else{ + led=1; + m=0; + j=0;} + + + switch(j){ + case 2: + if(j==t){ + m=0; + led=1; + jd.printf("negro\n"); + wait(5); + m=1; + wait(9); + m=0; + } + break;} + + + } +}