int aPin=A5;
int ledCount= 10;
int ledPins[]={4,5,6,7,8,9,10,11,12,13};
void setup() {
// put your setup code here, to run once:
for (int a=0; a<ledCount; a++)
{
pinMode(ledPins[a], OUTPUT);
}
}
void loop() {
// put your main code here, to run repeatedly:
int sensorReading =analogRead(aPin);
int ledlevel= map(sensorReading, 0, 1023 , 0 , ledCount);
for ( int a=0; a<ledCount; a++)
{
if (a<ledlevel)
{
digitalWrite(ledPins[a], HIGH);
}
else
{
digitalWrite(ledPins[a], LOW);
}
}
}