int value;
int num_leds = 10;
float resistance;
int out_pins[] = {3,4,5,6,7,8,9,10,11,12};
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
for (int i = 0; i < num_leds; i++ ){
pinMode(out_pins[i], OUTPUT);
}
for(int i= 0; i<num_leds;i++){
digitalWrite(out_pins[i], HIGH);
delay(63);
}
for(int i= 0; i<num_leds;i++){
digitalWrite(out_pins[i], LOW);
delay(63);
}
for(int j = num_leds-1; j>=0;j--){
digitalWrite(out_pins[j], HIGH);
delay(63);
}
for(int i= num_leds-1; i>=0;i--){
digitalWrite(out_pins[i], LOW);
delay(63);
}
}
void loop() {
// put your main code here, to run repeatedly:
value = analogRead(A0);
int ledlvl = map(value,0,1023,0,num_leds);
for(int led = 0; led <num_leds;led++){
if(led < ledlvl){
digitalWrite(out_pins[led],HIGH);
}
else{
digitalWrite(out_pins[led],LOW);
}
}
}