Analog Pot Progress Led Bar


Potansiyometredeki değeri Ledlere aktarma uygulaması.

Kullanılan Malzemeler;
 1 Adet 10K Potansiyometre
10 Adet 220R 1/4W Direnç
10 Adet Sarı Led




const int LED[10] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
int X=0;
int DEGER;

void setup(){
for(X=0; X<10; X++){
 pinMode(LED[X], OUTPUT);
 }
}

void loop(){
 DEGER = analogRead(A0);
  delay(1);
     
  if(DEGER<24){
   digitalWrite(LED[0], LOW);
   digitalWrite(LED[1], LOW);
   digitalWrite(LED[2], LOW);
   digitalWrite(LED[3], LOW);
   digitalWrite(LED[4], LOW);
   digitalWrite(LED[5], LOW);
   digitalWrite(LED[6], LOW);
   digitalWrite(LED[7], LOW);
   digitalWrite(LED[8], LOW);
   digitalWrite(LED[9], LOW);
  }
  else if(DEGER>=24 && DEGER<200){
   digitalWrite(LED[0], HIGH);
   digitalWrite(LED[1], LOW);
   digitalWrite(LED[2], LOW);
   digitalWrite(LED[3], LOW);
   digitalWrite(LED[4], LOW);
   digitalWrite(LED[5], LOW);
   digitalWrite(LED[6], LOW);
   digitalWrite(LED[7], LOW);
   digitalWrite(LED[8], LOW);
   digitalWrite(LED[9], LOW);
  }
  else if(DEGER>=200 && DEGER<300){
   digitalWrite(LED[0], HIGH);
   digitalWrite(LED[1], HIGH);
   digitalWrite(LED[2], LOW);
   digitalWrite(LED[3], LOW);
   digitalWrite(LED[4], LOW);
   digitalWrite(LED[5], LOW);
   digitalWrite(LED[6], LOW);
   digitalWrite(LED[7], LOW);
   digitalWrite(LED[8], LOW);
   digitalWrite(LED[9], LOW);
  }
  else if(DEGER>=300 && DEGER<400){
   digitalWrite(LED[0], HIGH);
   digitalWrite(LED[1], HIGH);
   digitalWrite(LED[2], HIGH);
   digitalWrite(LED[3], LOW);
   digitalWrite(LED[4], LOW);
   digitalWrite(LED[5], LOW);
   digitalWrite(LED[6], LOW);
   digitalWrite(LED[7], LOW);
   digitalWrite(LED[8], LOW);
   digitalWrite(LED[9], LOW);
  }
  else if(DEGER>=400 && DEGER<500){
   digitalWrite(LED[0], HIGH);
   digitalWrite(LED[1], HIGH);
   digitalWrite(LED[2], HIGH);
   digitalWrite(LED[3], HIGH);
   digitalWrite(LED[4], LOW);
   digitalWrite(LED[5], LOW);
   digitalWrite(LED[6], LOW);
   digitalWrite(LED[7], LOW);
   digitalWrite(LED[8], LOW);
   digitalWrite(LED[9], LOW);
  }
  else if(DEGER>=500 && DEGER<600){
   digitalWrite(LED[0], HIGH);
   digitalWrite(LED[1], HIGH);
   digitalWrite(LED[2], HIGH);
   digitalWrite(LED[3], HIGH);
   digitalWrite(LED[4], HIGH);
   digitalWrite(LED[5], LOW);
   digitalWrite(LED[6], LOW);
   digitalWrite(LED[7], LOW);
   digitalWrite(LED[8], LOW);
   digitalWrite(LED[9], LOW);
  }
  else if(DEGER>=600 && DEGER<700){
   digitalWrite(LED[0], HIGH);
   digitalWrite(LED[1], HIGH);
   digitalWrite(LED[2], HIGH);
   digitalWrite(LED[3], HIGH);
   digitalWrite(LED[4], HIGH);
   digitalWrite(LED[5], HIGH);
   digitalWrite(LED[6], LOW);
   digitalWrite(LED[7], LOW);
   digitalWrite(LED[8], LOW);
   digitalWrite(LED[9], LOW);
  }
  else if(DEGER>=700 && DEGER<800){
   digitalWrite(LED[0], HIGH);
   digitalWrite(LED[1], HIGH);
   digitalWrite(LED[2], HIGH);
   digitalWrite(LED[3], HIGH);
   digitalWrite(LED[4], HIGH);
   digitalWrite(LED[5], HIGH);
   digitalWrite(LED[6], HIGH);
   digitalWrite(LED[7], LOW);
   digitalWrite(LED[8], LOW);
   digitalWrite(LED[9], LOW);
  }
  else if(DEGER>=800 && DEGER<900){
   digitalWrite(LED[0], HIGH);
   digitalWrite(LED[1], HIGH);
   digitalWrite(LED[2], HIGH);
   digitalWrite(LED[3], HIGH);
   digitalWrite(LED[4], HIGH);
   digitalWrite(LED[5], HIGH);
   digitalWrite(LED[6], HIGH);
   digitalWrite(LED[7], HIGH);
   digitalWrite(LED[8], LOW);
   digitalWrite(LED[9], LOW);
  }
  else if(DEGER>=900 && DEGER<1000){
   digitalWrite(LED[0], HIGH);
   digitalWrite(LED[1], HIGH);
   digitalWrite(LED[2], HIGH);
   digitalWrite(LED[3], HIGH);
   digitalWrite(LED[4], HIGH);
   digitalWrite(LED[5], HIGH);
   digitalWrite(LED[6], HIGH);
   digitalWrite(LED[7], HIGH);
   digitalWrite(LED[8], HIGH);
   digitalWrite(LED[9], LOW);
  }
  else if(DEGER>=1000 && DEGER<1024){
   for(X=0; X<10; X++){
   digitalWrite(LED[X], HIGH);
  }
 }
}

0 yorum: