# Control Multiple LED Brightness/Dim with One Potentiometer

**URL:** <https://forum.arduino.cc/t/control-multiple-led-brightness-dim-with-one-potentiometer/1408056>\
**Category:** LEDs and Multiplexing\
**Created:** [September 30, 2025, 8:13pm UTC](https://forum.arduino.cc/t/control-multiple-led-brightness-dim-with-one-potentiometer/1408056 "2025-09-30T20:13:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![simkanich](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/simkanich/32/1239088_2.png) [@simkanich](https://forum.arduino.cc/u/simkanich)\
**Post date:** [September 30, 2025, 8:13pm UTC](https://forum.arduino.cc/t/control-multiple-led-brightness-dim-with-one-potentiometer/1408056/1 "2025-09-30T20:13:07Z")

</div>

Hi. I am trying to dim multiple LED's using one potentiometer. I am first completing this in TinkerCad. I am able to turn the LED's on and off, but I seem to be missing something as far as controlling the amount of electricity is going to the LED's to control how bright it is. I am trying to keep the code simple, but any advice would be helpful. I am trying to not use the map function.

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/9/9/6/9967862615cf039c4a5e3526ff541093c355a628.png)

```arduino
//Pin Definitions
const int RedPin1 = 4;//Red1 connected to pin 4
const int RedPin2 = 6;//Red2 connected to pin 6
const int GreenPin1 = 8;//Green1 connected to pin 8
const int GreenPin2 = 10;//Green2 connected to pin 10
int potPin = A0; // Potentiometer pin
int inputValue = 0; // int to keep track of the values coming from the Potentiometer

void setup() {
  // LED pins 
pinMode (RedPin1, OUTPUT);
pinMode (RedPin2, OUTPUT);
pinMode (GreenPin1, OUTPUT);
pinMode (GreenPin2, OUTPUT);
pinMode (potPin, INPUT);
   
}

void loop() {
  // Program multiple LED Lights to Turn ON and OFF
inputValue = analogRead(potPin); // gets value from sensor

digitalWrite (RedPin1, HIGH);
digitalWrite (RedPin2, HIGH);
digitalWrite (GreenPin1, HIGH);
digitalWrite (GreenPin2, HIGH);
delay (3000);

digitalWrite (RedPin1, LOW);
digitalWrite (RedPin2, LOW);
digitalWrite (GreenPin1, LOW);
digitalWrite (GreenPin2, LOW);
delay (1000);
  
 
}

```

---

<div class="post-metadata">

**Author:** ![PaulRB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paulrb/32/216330_2.png) [@PaulRB](https://forum.arduino.cc/u/PaulRB)\
**Post date:** [September 30, 2025, 8:26pm UTC](https://forum.arduino.cc/t/control-multiple-led-brightness-dim-with-one-potentiometer/1408056/2 "2025-09-30T20:26:59Z")

</div>

To control the brightness of LEDs you must use analogWrite() instead of digitalWrite().

analogWrite() only works with the Arduino pins that have the ~ symbol next to their pin numbers.

> [@simkanich](#):
>
> I am trying to not use the map function.

So far, you have succeeded! But why do you not want to use that function?

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [September 30, 2025, 8:37pm UTC](https://forum.arduino.cc/t/control-multiple-led-brightness-dim-with-one-potentiometer/1408056/3 "2025-09-30T20:37:07Z")

</div>

Welcome to the forum

You are reding the pot then ignoring the value that you have read

when you read the pot into an int variable you will get a value between 0 and 1023. To control the brightness of the LEDs they must be connected to PWM pins and you must write a value between 0 and 255 using analogWrite().

To avoid the use of the map() function (why ?) just divide the value read from the pot by 4 and write it to the LEDs

---

<div class="post-metadata">

**Author:** ![simkanich](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/simkanich/32/1239088_2.png) [@simkanich](https://forum.arduino.cc/u/simkanich)\
**Post date:** [September 30, 2025, 11:59pm UTC](https://forum.arduino.cc/t/control-multiple-led-brightness-dim-with-one-potentiometer/1408056/4 "2025-09-30T23:59:16Z")

</div>

Thank you for the feedback. I wasn’t sure if the map function was need, but it appears that the map function must be included for the voltage divider and the analogWrite with the PWM pins. I appreciate the help.

Here is my working copy:

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/f/d/f/fdf6fd19d16b63cc1ac4473d36285c97331b9175.png)

```arduino
//Pin Definitions
const int RedPin1 = 3;//PWM Pin 3 - Red1 connected
const int RedPin2 = 5;//PWM Pin 5 - Red2 connected
const int GreenPin1 = 6;//PWM Pin 6 - Green1 connected
const int GreenPin2 = 10;//PWM Pin 10 - Green2 connected
int potPin = A0; // Potentiometer pin
int inputValue = 0; // int to keep track of the values coming from the Potentiometer

void setup() {
  // LED pins 
pinMode (RedPin1, OUTPUT);
pinMode (RedPin2, OUTPUT);
pinMode (GreenPin1, OUTPUT);
pinMode (GreenPin2, OUTPUT);
//pinMode (potPin, INPUT);
   
}

void loop() {

  // Gets the Value from the Potentiometer 
inputValue = analogRead(potPin);  
  
// Map the potentiometer value to the LED brightness range (0-255)
  int brightness = map(inputValue, 0, 1023, 0, 255);
  

  
// Write brightness to each LED individually
analogWrite (RedPin1, brightness);
analogWrite (RedPin2, brightness);
analogWrite (GreenPin1, brightness);
analogWrite (GreenPin2, brightness);
  
 
}

```

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [October 1, 2025, 5:33am UTC](https://forum.arduino.cc/t/control-multiple-led-brightness-dim-with-one-potentiometer/1408056/5 "2025-10-01T05:33:40Z")

</div>

> [@simkanich](#):
>
> it appears that the map function must be included for the voltage divider

No, use of the map() function is not necessary. Simply divide the value read from the pot by 4 instead, as I previously suggested

---

<div class="post-metadata">

**Author:** ![PaulRB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paulrb/32/216330_2.png) [@PaulRB](https://forum.arduino.cc/u/PaulRB)\
**Post date:** [October 1, 2025, 5:36am UTC](https://forum.arduino.cc/t/control-multiple-led-brightness-dim-with-one-potentiometer/1408056/6 "2025-10-01T05:36:20Z")

</div>

> [@simkanich](#):
>
> the map function must be included for the voltage divider and the analogWrite with the PWM pins

Also incorrect. There is nearly always more than one way to achieve a feature in your code.

For example

```arduino
  // Map the potentiometer value to the LED brightness range (0-255)
  int brightness = inputValue / 4;

```

or

```arduino
  // Map the potentiometer value to the LED brightness range (0-255)
  int brightness = inputValue >> 2;

```

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [March 30, 2026, 5:36am UTC](https://forum.arduino.cc/t/control-multiple-led-brightness-dim-with-one-potentiometer/1408056/7 "2026-03-30T05:36:22Z")

</div>

Closed on March 30, 2026, 5:36am UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
