I am trying to build an array of LEDs where their brightness is controlled by a potentiometer. The LCD will display the percentage of brightness based on the potentiometer. I am able to successfully control the brightness of a circuit with only one LED. However, I am having trouble with 2 two LEDs in series (which are in parallel with other sets of 2 LEDs in series). And I believe the problem is that the Arduino is only supplying enough voltage to power one LED (maybe < 5V). How can I properly wire a 9V battery to this circuit in which the potentiometer can control the amount voltage coming from this battery? Are Arduinos only capable of controlling <5V with a potentiometer?
Here is my code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int potPin = A0;
int ledPin = 6;
int potValue = 0;
void setup() {
pinMode(potPin, INPUT);
pinMode(ledPin, OUTPUT);
lcd.begin(16, 2);
lcd.print("Potentiometer");
}
void loop() {
potValue = (analogRead(potPin)/10.02);
analogWrite(ledPin, potValue);
lcd.setCursor(0,1);
lcd.print(potValue);
lcd.print("%");
delay(100);
lcd.print(" ");
delay(1);
}
And here is a picture of my circuit setup: