const int analogPin = A0;
int ledPins[] = {2,3,4,5,6};
int num_10bit,num_05;
void setup() {
//loop over the pin array and set them all to output:
for (int thisLed = 2; thisLed < ledPins; thisLed++) {
pinMode(ledPins[thisLed], OUTPUT);
}
}
void loop() {
num_10bit=analogRead(analogPin);
num_05=map(num_10bit,0,1023,0,5);
led_level() ;
for (int thisLed= 0; thisLed<5; thisLed++) {
digitalWrite(ledPins[thisLed], LOW);
}
}
void led_level(){
for (int thisLed=0; thisLed<num_05; thisLed++) {
digitalWrite(ledPins[thisLed], HIGH);
}
}