#define poten A5
#define led 13
#define led2 12
#define led3 11
#define led4 10
#define led5 9
void setup() {
// put your setup code here, to run once:
pinMode (poten ,INPUT );
pinMode (led,OUTPUT );
pinMode (led2,OUTPUT );
pinMode (led3,OUTPUT);
pinMode (led4,OUTPUT );
pinMode (led5,OUTPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
float value = analogRead( poten );
float percent = (value/1023)*100;
if(percent >= 20)
{
digitalWrite (led,HIGH);
digitalWrite (led2 ,LOW);
digitalWrite (led3 ,LOW);
digitalWrite (led4 ,LOW);
digitalWrite (led5,LOW );
}
if (percent >= 40)
{
digitalWrite (led,LOW );
digitalWrite (led2 ,HIGH );
digitalWrite (led3 ,LOW );
digitalWrite (led4 ,LOW);
digitalWrite (led5 ,LOW);
}
if (percent >=60)
{
digitalWrite (led,LOW);
digitalWrite (led2 ,LOW);
digitalWrite (led3 , HIGH);
digitalWrite (led4 ,LOW);
digitalWrite (led5 ,LOW);
}
if (percent >= 80)
{
digitalWrite (led ,LOW);
digitalWrite (led2 ,LOW);
digitalWrite (led3 ,LOW);
digitalWrite (led4 , HIGH);
digitalWrite (led5 ,LOW);
}
if (percent >= 80)
{
digitalWrite (led,LOW);
digitalWrite (led2 ,LOW);
digitalWrite (led3 ,LOW);
digitalWrite (led4 , HIGH);
digitalWrite (led5 ,LOW);
}
if (percent >= 100)
{
digitalWrite (led,LOW);
digitalWrite (led2 ,LOW);
digitalWrite (led3 ,LOW);
digitalWrite (led4 ,LOW);
digitalWrite (led5 , HIGH);
}
if (percent <= 20)
digitalWrite (led,LOW);
}