Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

Fading/Controlling led/brightness using Potentiometer (Variable Resistor) and Arduino Uno

By EG Projects August 18, 2020

Fading or controlling led brightness using arduino uno and potentiometer/variable resistor is not a very hard task. Arduino predefined libraries made it very easy to fade led with arduino uno. Whats going behind the arduino code predefined commands/instructions at software and at hardware level is important to understand. Students normally start with the pre-written arduino code examples available with in the arduino ide and never try to understand what actually is happening behind the visible spectrum. So when they move to higher level of arduino programming they face hurdles in properly designing the circuit and implementing the code logic for the particular hardware. In this tutorial i will explain how to control brightness of a led using arduino and a potentiometer/variable resistor.

One can find the arduino analog fade and arduino serial in/out example in the arduino ide. The examples are more or less same to what i am going to discuss in this tutorial. I will go deeper and try to highlight every piece of information widely and as easily as i could.

Potentiometer is used in the circuits where we need a variable resistance to control current and voltage. Have you noticed that, the speaker that you have in your home, you move its knob in clockwise and anti clock wise direction to set the volume. Actually behind the knob their is a potentiometer, that is you are varying the resistance to set the volume. Like wise in many other home appliances potentiomenter is used for the same purpose(old TV’s , old radios etc).

Potentiometer/variable resistor controlling led brightness

Potentiometer/variable resistor controlling led brightness

What happens at the potentiometer side?

When we rotate the knob of the potentiometer we actually are increasing or decreasing the resistance. Remember potentiometer is a variable resistor nothing else. The range of the potentiometer resistance is written on the potentiometer or you can manually check the data sheet of the particular potentiometer to verify its resistance. 

Now recall Ohms law that when ever resistance in a circuit increases the current decreases. Also current is directly proportional to voltage. So with the increase in voltage current increases and with decrease in voltage current decreases.

If we consider the above statement it is clear that we can directly connect the led with potentiometer and fade/dim/control its brightness by rotating the knob of the potentiometer. Then why we are trying to fade led with potentiometer using arduino? What are the pros and cons of fading led with potentiometer and arduino?

Why potentiometer with Arduino?

If we directly connect the led with potentiometer we can fade/control brightness of led but not accurately and if we insert and intermediate microcontroller then microcontroller can fade led with the brightness level we want. In direct controlling brightness depends on the resistance of the potentiometer but with microcontroller in between brightness depends on the voltage output of the potentiometer and some how we can even neglect the voltage output and control led on our defined parameters. With microcontroller their is more flexibility than the manually fading. 

Led brightness control with potentiometer and Arduino

How the system works?

Arduino analog input pin is connected to output of potentiometer. So arduino ADC(analog to digital converter) analog pin is reading the output voltage by the potentiometer. Rotating the potentiometer knob varies the voltage output and arduino reads this variation. Arduino converts the input voltage to its analog pin in to digital form. The digital value ranges from 0 to 1023 volts. 0 represents 0 volts and 1023 represents 5 volts. Arduino ADC is 10 bit which means it cam sample input voltage and output it in between range of 0 to 1023 volts (2^10 = 1024). Arduino works on 5 volts so its ADC input voltage range is also between 0 to 5 volts. Arduino boards working on 3 volts input range for ADC is 0 to 3 volts.

Note: Applying greater voltage to arduino analog pins will damage your arduino board. So in our case the potentiometer voltage output must not increase 5 volts.

Project Circuit

Potentiometer and led with Arduino Uno

Potentiometer and led with Arduino Uno

        

 

Fading led with potentiometer and arduino unoFading led with potentiometer and arduino uno

Coming to the schematic of the circuit. Apply 5 volt  to 12 volt to the +Pin(anode) of potentiometer and connect -Pin(cathode) to ground. Connect the output pin of potentiometer to the Analog input Pin-A0 of the ardunio. Now connect the led +pin(anode) to the pin#9 of Ardunio. Pin#9 is used as an analog output pin. Few arduino uno pins can be used to output variable voltage and pin#9 is one of them. It outputs analog values in the form of pwm(pulse width modulated signal). Connect the other end of led to ground in series with a resistance. Resistance can be in range of 120 ohm to 4.7 k ohm. Make the circuit and upload the sketch in your ardunio uno. 

         
Voltage Variation Fades Led

When you rotate the knob of the potentiometer resistance decreases and the current starts flowing. As the current increases the voltage increases and their is a change in voltage which is detected by the analog input A0 pin of the Arduino. We analyze this change in voltage in our sketch(code) and then output the change to Pin#9 to which our led is connected. Led fades when we constantly rotate the potentiometer knob in clockwise and anticlockwise direction.


Project Code

The code is simple first  arduino pin A0(analog) is declared as input and pin#9 is declared as analog output. In void loop function first the analog change is read from the A0 pin using the analogRead() function.Then the input value is divided by 4.
Its necessary to divide the analog reading by 4 because analogWrite() function outputs analog values in between range from 0 to 255. Where 0 represents low and 255 represent high, and analogRead() inputs value from 0 to 1023. At last the analogWrite() function outputs the analog value. You will now see led fading/brightness varied if you rotate the knob of potentiometer.      
You can change the above code according to your desire. Controlling led brightness with arduino/microcontroller provides flexibility. You can now fade led on voltage increase or decrease in either direction. You can program the controller according to your desired configuration. With insertion of some other hardware like the motor controller circuit you can control the fan/motor speed and also the rotation direction. This all is possible only due to the intelligent unit microcontroller.
Fading Led using Potentiometer with arduino Download
Download the program code and sketch(.ino file ) Folder include code and .ino sketch of the project. If you have any questions regarding post or you want to say something about the project. Plz leave your queries below in the comments section.

 

Watch the Project Video Here

You may also like:

  • beginners guide
    Basic Electronics 01 – Beginners guide to setting up an…

  • What are the top technologies enabling M2M in 2023?

  • What are LoRa gateways and what types are available?

  • How does LoRa modulation enable long-range communication?

  • What are the two types of hardware filters?

  • What are hardware filters and their types?

Filed Under: Arduino Projects, Electronic Projects, Microcontroller Projects

 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • How to preserve hierarchical instance names like \adder_1/U1 in flattened gate-level netlist in Design Compiler?
  • Can anyone provide a guide or tutorial for Candece simulation?
  • Voltage mode pushpull is a nonsense SMPS?
  • High Side current sensing
  • MOSFET thermal noise in Weak vs Strong inversion

RSS Electro-Tech-Online.com Discussions

  • Photo interrupter Connections
  • Is AI making embedded software developers more productive?
  • Can I make two inputs from one??
  • Why can't I breadboard this oscillator?
  • Cataract Lens Options?

Featured – RPi Python Programming (27 Part)

  • RPi Python Programming 21: The SIM900A AT commands
  • RPi Python Programming 22: Calls & SMS using a SIM900A GSM-GPRS modem
  • RPi Python Programming 23: Interfacing a NEO-6MV2 GPS module with Raspberry Pi
  • RPi Python Programming 24: I2C explained
  • RPi Python Programming 25 – Synchronous serial communication in Raspberry Pi using I2C protocol
  • RPi Python Programming 26 – Interfacing ADXL345 accelerometer sensor with Raspberry Pi

Recent Articles

  • GigaDevice launches GD32C231 MCU series with 48MHz Cortex-M23 core and 64KB Flash
  • Advanced Energy releases 425 W CF-rated medical power supply in 3.5 x 6 x 1.5-inch format”
  • LEM combines shunt and Hall effect sensing in 2000 A current measurement unit
  • What is AWS IoT Core and when should you use it?
  • AC-DC power supply extends voltage range to 800 V DC

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe