4-2: LED VU metar

Dependencies:   mbed

main.cpp

Committer:
miljkovic
Date:
2015-12-03
Revision:
0:9df49e4b7c19

File content as of revision 0:9df49e4b7c19:

#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; 
           
        }
   
}
}