HW-269 LED Brightness Control Using Potentiometer

by devkrishnavhora in Circuits > Arduino

29 Views, 0 Favorites, 0 Comments

HW-269 LED Brightness Control Using Potentiometer

The objective of this project is to control the brightness of the HW-269 3W LED module using a potentiometer and an Arduino Nano.

Supplies

Components Required

  1. Deshbot shield
  2. Arduino Nano
  3. potentiometer
  4. HW-269 3W LED module


Pin Connections


HW-269

HW-269 PinArduino Nano

+ - 5V

S - D11

G - GND

Potentiometer

Potentiometer PinArduino Nano

Left pin - 5V

Middle pin - A0

Right pin

GNDPin Connections

HW-269

HW-269 PinArduino Nano

+ - 5V

S - D11

G - GND

Potentiometer

Potentiometer PinArduino Nano

Left pin - 5V

Middle pin - A0

Right pin - GND

Working


The potentiometer provides an analog voltage to A0. The Arduino Nano reads this value between 0 and 1023.

The map() function converts this value from 0–1023 into a PWM brightness value of 0–255.

Potentiometer
↓
A0
↓
0–1023
↓
0–255 PWM
↓
D11
↓
HW-269 LED

When the potentiometer is turned toward one side, the LED becomes dimmer. When it is turned toward the other side, the LED becomes brighter.

Arduino Code


#define LED 11
#define POT A0

void setup() {

pinMode(LED, OUTPUT);

}

void loop() {

// Read potentiometer
int potValue = analogRead(POT);

// Convert 0-1023 to 0-255
int brightness = map(potValue, 0, 1023, 0, 255);

// Set LED brightness
analogWrite(LED, brightness);

delay(10);
}

Main Functions Used

  1. analogRead() — reads the potentiometer value.
  2. map() — converts the potentiometer value to a PWM range.
  3. analogWrite() — controls the LED brightness using PWM.
  4. D11 is used because it supports PWM on the Arduino Nano.


Result


The HW-269 3W LED brightness can be smoothly controlled using the potentiometer, from dim/off to maximum brightness.