Using a Potentiometer to Control 3 LEDs"
by STEAM-DIY in Circuits > Arduino
66 Views, 2 Favorites, 0 Comments
Using a Potentiometer to Control 3 LEDs"
Project Overview
In this project, we'll use a potentiometer to control the brightness of three LEDs connected to an Arduino. The potentiometer will act as a variable resistor, changing the voltage and thus controlling the brightness of the LEDs.
Supplies
Materials Needed
- Arduino Uno
- Breadboard
- Potentiometer (10k ohms)
- 3 LEDs (any color)
- 3 Resistors (220 ohms)
- Jumper wires
- USB cable (for connecting Arduino to the computer)
Circuit Diagram
Refer to the image you provided for the circuit setup.
- Arduino Pins:
- Connect the GND pin of the Arduino to the ground rail of the breadboard.
- Connect the 5V pin of the Arduino to the positive rail of the breadboard.
- Connect pins 9, 10, and 11 of the Arduino to three different rows on the breadboard (for controlling the LEDs).
- Potentiometer Connections:
- The left pin of the potentiometer is connected to the 5V rail.
- The right pin is connected to the GND rail.
- The middle pin is connected to analog pin A0 of the Arduino.
- LED Connections:
- Connect the anode (long leg) of each LED to the corresponding digital pins (9, 10, and 11).
- Connect the cathode (short leg) of each LED to one end of a 220-ohm resistor.
- Connect the other end of each resistor to the GND rail of the breadboard.
Arduino Code
Explanation of the Code
- Variables: potPin, led1, led2, and led3 store the pin numbers.
- setup(): Sets the LED pins as OUTPUT.
- loop(): Continuously reads the potentiometer value and maps it to LED brightness. Each LED will behave differently based on the mapped value, providing visual feedback of the potentiometer position.
Testing the Project
- Upload the code to your Arduino using the Arduino IDE.
- Turn the potentiometer knob and observe the changes in the brightness of the LEDs. Each LED should show a different pattern of brightness variation.
Conclusion
This project is a simple yet effective way to demonstrate the use of a potentiometer in controlling multiple outputs on an Arduino. It's great for beginners to understand analog input and PWM output in a practical context.
project link
https://www.tinkercad.com/things/lJvZ68s5tP3-how-to-use-potentiometer-controls-3-leds-by-zorro-alpha
and subscribe my channel please.
https://youtube.com/@steam-diy?si=EuZwV7HjRYV-SusJ
thanks