Multiple LED Bar Graphs

Tom Igoe created the code for the LED Bar Graph.
It mainly consists of a potentiometer and 1 bar of 10 LED lights.

But I was wondering if you could do the same with 3 potentiometers and 3 rows of 10 LED lights.
With each individual potentiometer controlling a LED row.

Like for instance, Bar_1; 6 LED, Bar_2; 8 LED and Bar_3; 2 LED

I’ve tried to combine the codes, but it doesn’t seem to work.
I am quite new to this.

The code looks like this:

// these constants won't change:
const int analogPin0 = A0;   // the pin that the potentiometer is attached to
const int analogPin1 = A1;
const int analogPin2 = A2;
const int ledCount1 = 10;    // the number of LEDs in the bar graph
const int ledCount2 = 10;
const int ledCount3 = 10;

int ledPins1[] = {
  2, 3, 4, 5, 6, 7, 8, 9, 10, 11
};   // an array of pin numbers to which LEDs are attached
int ledPins2[] = {
  20, 21, 22, 23, 24, 25, 26, 27, 28, 29
}; 
int ledPins3[] = {
  30, 31, 32, 33, 34, 35, 36, 37, 38, 49
}; 

void setup() {
  // loop over the pin array and set them all to output:
  for (int thisLed = 0; thisLed < ledCount1; thisLed++) {
    pinMode(ledPins1[thisLed], OUTPUT);
  }
  for (int thisLed = 0; thisLed < ledCount2; thisLed++) {
    pinMode(ledPins2[thisLed], OUTPUT);
  }
  for (int thisLed = 0; thisLed < ledCount3; thisLed++) {
    pinMode(ledPins3[thisLed], OUTPUT);
  }
 }

void loop() {
  // read the potentiometer:
  int sensorReading1 = analogRead(analogPin0);
  // map the result to a range from 0 to the number of LEDs:
  int ledLevel1 = map(sensorReading1, 0, 1023, 0, ledCount1);

  // loop over the LED array:
  for (int thisLed = 0; thisLed < ledCount1; thisLed++) {
    // if the array element's index is less than ledLevel,
    // turn the pin for this element on:
    if (thisLed < ledLevel1) {
      digitalWrite(ledPins1[thisLed], HIGH);
    }
    // turn off all pins higher than the ledLevel:
    else {
      digitalWrite(ledPins1[thisLed], LOW);
    }
  }
 
    // read the potentiometer:
  int sensorReading2 = analogRead(analogPin1);
  // map the result to a range from 0 to the number of LEDs:
  int ledLevel2 = map(sensorReading1, 0, 1023, 0, ledCount2);

  // loop over the LED array:
  for (int thisLed = 0; thisLed < ledCount2; thisLed++) {
    // if the array element's index is less than ledLevel,
    // turn the pin for this element on:
    if (thisLed < ledLevel2) {
      digitalWrite(ledPins2[thisLed], HIGH);
    }
    // turn off all pins higher than the ledLevel:
    else {
      digitalWrite(ledPins2[thisLed], LOW);
    }
  }
 
  int sensorReading3 = analogRead(analogPin2);
  // map the result to a range from 0 to the number of LEDs:
  int ledLevel3 = map(sensorReading1, 0, 1023, 0, ledCount3);

  // loop over the LED array:
  for (int thisLed = 0; thisLed < ledCount3; thisLed++) {
    // if the array element's index is less than ledLevel,
    // turn the pin for this element on:
    if (thisLed < ledLevel3) {
      digitalWrite(ledPins3[thisLed], HIGH);
    }
    // turn off all pins higher than the ledLevel:
    else {
      digitalWrite(ledPins3[thisLed], LOW);
    }
  }
}

Thank you for your answers and suggestions.

What does your code actually do?

but it doesn't seem to work

That is a useless thing to say. Would you take your car into a garage, say that, and leave them to it?

PaulRB:
That is a useless thing to say. Would you take your car into a garage, say that, and leave them to it?

+1. Love it!

Not sure why you have sensorReading1 in the ledLevel2 section. Should this be sensorReading2 instead?

int ledLevel2 = map(sensorReading1, 0, 1023, 0, ledCount2);

Should this be sensorReading3 instead:

int ledLevel3 = map(sensorReading1, 0, 1023, 0, ledCount3);

Not sure I fully understand your goal but maybe those will help.

I would worry about the overall current draw if all the LED's are lit.