4-2: LED VU metar

Dependencies:   mbed

Revision:
0:9df49e4b7c19
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Dec 03 17:59:28 2015 +0000
@@ -0,0 +1,61 @@
+#include "mbed.h"
+Serial pc(USBTX, USBRX);
+AnalogIn Ain(p20);
+
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+DigitalOut led3(LED3);
+DigitalOut led4(LED4);
+
+int main() {
+ float ADCdata;
+ 
+while (1) {
+ADCdata=Ain;
+pc.printf("%f \n\r",ADCdata);
+ 
+ 
+        if(ADCdata<0.2)
+        {
+           myled1=0; 
+           myled2=0; 
+           myled3=0; 
+           myled4=0; 
+           
+        }
+        if((ADCdata>0.2)&&(ADCdata<0.4))
+        {
+           myled1=1; 
+           myled2=0; 
+           myled3=0; 
+           myled4=0; 
+           
+        }
+         if((ADCdata>0.4)&&(ADCdata<0.6))
+        {
+           myled1=1; 
+           myled2=1; 
+           myled3=0; 
+           myled4=0; 
+           
+        }
+         if((ADCdata>0.6)&&(ADCdata<0.8))
+        {
+           myled1=1; 
+           myled2=1; 
+           myled3=1; 
+           myled4=0; 
+           
+        }
+        if((ADCdata>0.8)&&(ADCdata<=1))
+         
+        {
+           myled1=1; 
+           myled2=1; 
+           myled3=1; 
+           myled4=1; 
+           
+        }
+   
+}
+}
\ No newline at end of file