#define POT_PIN 27
int LED[] = {13, 4, 2, 15, 23, 22, 21, 19, 18, 5};
void setup() {
Serial.begin(115200);
pinMode(POT_PIN, INPUT);
for(int i = 0; i < 10; i++){
pinMode(LED[i], OUTPUT);
digitalWrite(LED[i], HIGH);
}
}
void loop() {
int potValue = analogRead(POT_PIN)/16;
Serial.println(potValue);
if(potValue > 230){
for(int i = 0; i < 10; i++){
digitalWrite(LED[i], LOW);
}
}else if(potValue > 205 && potValue <= 230){
for(int i = 0; i < 10; i++){
if(i < 9) digitalWrite(LED[i], LOW);
else digitalWrite(LED[i], HIGH);
}
}else if(potValue > 180 && potValue <= 205){
for(int i = 0; i < 10; i++){
if(i < 8) digitalWrite(LED[i], LOW);
else digitalWrite(LED[i], HIGH);
}
}else if(potValue > 155 && potValue <= 180){
for(int i = 0; i < 10; i++){
if(i < 7) digitalWrite(LED[i], LOW);
else digitalWrite(LED[i], HIGH);
}
}else if(potValue > 130 && potValue <= 155){
for(int i = 0; i < 10; i++){
if(i < 6) digitalWrite(LED[i], LOW);
else digitalWrite(LED[i], HIGH);
}
}else if(potValue > 105 && potValue <= 130){
for(int i = 0; i < 10; i++){
if(i < 5) digitalWrite(LED[i], LOW);
else digitalWrite(LED[i], HIGH);
}
}else if(potValue > 80 && potValue <= 105){
for(int i = 0; i < 10; i++){
if(i < 4) digitalWrite(LED[i], LOW);
else digitalWrite(LED[i], HIGH);
}
}else if(potValue > 55 && potValue <= 80){
for(int i = 0; i < 10; i++){
if(i < 3) digitalWrite(LED[i], LOW);
else digitalWrite(LED[i], HIGH);
}
}else if(potValue > 25 && potValue <= 55){
for(int i = 0; i < 10; i++){
if(i < 2) digitalWrite(LED[i], LOW);
else digitalWrite(LED[i], HIGH);
}
}else if(potValue > 0 && potValue <= 25){
for(int i = 0; i < 10; i++){
if(i < 1) digitalWrite(LED[i], LOW);
else digitalWrite(LED[i], HIGH);
}
}else{
for(int i = 0; i < 10; i++){
digitalWrite(LED[i], HIGH);
}
}
delay(20); // this speeds up the simulation
}