nicolás rodríguez
/
adc
Conversor ADC con leds
Revision 0:75d0e094aebd, committed 2017-08-19
- Comitter:
- nikor97r
- Date:
- Sat Aug 19 20:22:42 2017 +0000
- Commit message:
- Conversor ADC con leds
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 |
diff -r 000000000000 -r 75d0e094aebd main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Aug 19 20:22:42 2017 +0000 @@ -0,0 +1,225 @@ +#include "mbed.h" +AnalogIn adc(A1); +DigitalOut led1(D13); +DigitalOut led2(D2); +DigitalOut led3(D3); +DigitalOut led4(D4); +DigitalOut led5(D5); +DigitalOut led6(D6); +DigitalOut led7(D7); +DigitalOut led8(D8); +DigitalOut led9(D9); +DigitalOut led10(D10); +DigitalOut led11(D11); +DigitalOut led12(D12); +float conversion; +float conversion1; +int main() + { + led1=1; + led2=0; + led3=0; + led4=0; + led5=0; + led6=0; + led7=0; + led8=0; + led9=0; + led10=0; + led11=0; + led12=0; + while(1) + { + conversion = adc.read_u16(); + conversion1 = (conversion*0.00005); + + while(conversion1 <=0.275 && conversion1 >0) + { + + conversion = adc.read_u16(); + conversion1 = (conversion*0.00005); + led1=1; + + wait(0.1); + } + led1=0; + + while(conversion1 <=(0.275*2) && conversion1 >0.275) + { + conversion = adc.read_u16(); + conversion1 = (conversion*0.00005); + led2=1; + led1=1; + + wait(0.1); + } + led2=0; + while(conversion1 <=(0.275*3) && conversion1 >(0.275*2)) + { + + conversion = adc.read_u16(); + conversion1 = (conversion*0.00005); + led3=1; + led1=1; + led2=1; + + wait(0.1); + } + led3=0; + while(conversion1 <=(0.275*4) && conversion1 >(0.275*3)) + { + conversion = adc.read_u16(); + conversion1 = (conversion*0.00005); + led4=1; + led3=1; + led2=1; + led1=1; + + wait(0.1); + } + led4=0; + while(conversion1 <=(0.275*5) && conversion1 >(0.275*4)) + { + conversion = adc.read_u16(); + conversion1 = (conversion*0.00005); + led5=1; + led4=1; + led3=1; + led2=1; + led1=1; + + wait(0.1); + } + led5=0; + while(conversion1 <=0.275*6 && conversion1 >0.275*5) + { + conversion = adc.read_u16(); + conversion1 = (conversion*0.00005); + led6=1; + led5=1; + led4=1; + led3=1; + led2=1; + led1=1; + + wait(0.1); + } + led6=0; + while(conversion1 <=(0.275*7) && conversion1 >(0.275*6)) + { + conversion = adc.read_u16(); + conversion1 = (conversion*0.00005); + led7=1; + led6=1; + led5=1; + led4=1; + led3=1; + led2=1; + led1=1; + + wait(0.1); + } + led7=0; + + while(conversion1 <=(0.275*8) && conversion1 >(0.275*7)) + { + conversion = adc.read_u16(); + conversion1 = (conversion*0.00005); + led8=1; + led7=1; + led6=1; + led5=1; + led4=1; + led3=1; + led2=1; + led1=1; + + wait(0.1); + } + led8=0; + + while(conversion1 <=(0.275*9) && conversion1 >(0.275*8)) + { + conversion = adc.read_u16(); + conversion1 = (conversion*0.00005); + led9=1; + led8=1; + led7=1; + led6=1; + led5=1; + led4=1; + led3=1; + led2=1; + led1=1; + + wait(0.1); + } + led9=0; + + while(conversion1 <=(0.275*10) && conversion1>(0.275*9)) + { + conversion = adc.read_u16(); + conversion1 = (conversion*0.00005); + led10=1; + led9=1; + led8=1; + led7=1; + led6=1; + led5=1; + led4=1; + led3=1; + led2=1; + led1=1; + + wait(0.1); + } + led10=0; + + while(conversion1 <=(0.275*11) && conversion1 >(0.275*10)) + { + conversion = adc.read_u16(); + conversion1 = (conversion*0.00005); + led11=1; + led10=1; + led9=1; + led8=1; + led7=1; + led6=1; + led5=1; + led4=1; + led3=1; + led2=1; + led1=1; + + wait(0.1); + } + led11=0; + + while(conversion1 <=(0.275*12) && conversion1 >(0.275*11)) + { + conversion = adc.read_u16(); + conversion1 = (conversion*0.00005); + led12=1; + led11=1; + led10=1; + led9=1; + led8=1; + led7=1; + led6=1; + led5=1; + led4=1; + led3=1; + led2=1; + led1=1; + + + wait(0.1); + } + led12=0; + + + + } + + } +
diff -r 000000000000 -r 75d0e094aebd mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Aug 19 20:22:42 2017 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/mbed_official/code/mbed/builds/e2bfab296f20 \ No newline at end of file