0

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:

LED array with potentiometer, LCD, and Arduino

1 Answer 1

3

Yes, Arduino is a 5V microcontroller, meaning it can directly control 5V circuits only. You might incur in problems also trying to deal with 3.3V circuits, even if Arduino is pretty friendly to 3.3V counterparts.

That does not mean though you cannot control higher voltage circuits, just not directly. Actually if anything above 6V is connected to an Arduino PIN you will blow that pin and potentially others which are logically connected within the MCU, so be aware.

To control higher voltage circuits you have multiple options, in your case you are probably interested into using a BJT transistor, an 2N2222 might do.

schematic

simulate this circuit – Schematic created using CircuitLab

Please note the values of R1 and R2 must be adjusted to the LEDs you are using depending on their Vf (forward voltage drop) and the maximum current you want to provide.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.