const int AnalogIN = A0;
const int LED_number = 10;
int LED[] = {
2,3,4,5,6,7,8,9,10,11
};
void setup() {
// put your setup code here, to run once:
for (int ThisLED = 0; ThisLED<LED_number; ThisLED++)
{
pinMode(LED[ThisLED],OUTPUT);
}
}
void loop() {
// put your main code here, to run repeatedly:
int SensorReading = analogRead(AnalogIN);
int LED_Level = map(SensorReading, 0, 1023, 0, LED_number);
for (int ThisLED = 0; ThisLED<LED_number; ThisLED++)
{
if (ThisLED < LED_Level)
{
digitalWrite(LED[ThisLED], HIGH);
}
else
{
digitalWrite(LED[ThisLED], LOW);
}
}
}