Conversor ADC con leds

Dependencies:   mbed

Files at this revision

API Documentation at this revision

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
--- /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;
+        
+        
+        
+    }
+    
+    }
+
--- /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