Engineers Garage

  • Electronics Projects and 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

ATtiny85 microcontroller tutorials, Part 6: LED intensity control using potentiometer and ATtiny85

By Ashutosh Bhatt October 27, 2021

In previous tutorials of this series, we saw how to vary the intensity (brightness) of LEDs using the PWM output of ATtiny85.

This tutorial shall take it to the next step by varying LED brightness using a potentiometer (pot). The pot will give an analog output of 0 to 5V. ATtiny85 has an inbuilt ADC with 4 input channels and 10-bit resolution. ATtiny85 will take analog input from the pot and generate PWM output to vary LED intensity. Let’s see how it is done.

If you are not following this tutorial series from the beginning, you are requested to go through the following two tutorials that explain and demonstrate how to work with ATtiny85 and step by step guide to build a hello world (LED blinking) application.

How to work with ATtiny85
LED blinking using ATtiny85

Circuit diagram

Circuit connections
The circuit is built using only 3-4 components. One LED is connected to a PB0 pin (pin 5) and a PWM output pin. One 330 resistor is used to limit the current. The middle and slider terminal of the pot is connected to pin 3 that is analog input pin A2. The other two terminals of the pot are connected with 5V and Gnd, as shown. A 5 V supply is connected to a Vcc pin (8)

Circuit operation
When the pot is varied, it gives analog voltage output from 0 to 5V. This is given as analog input to ATtiny85. The inbuilt ADC of ATtiny85 will convert this into digital, giving a digital value between 0 to 1023 (because of 10-bit resolution). Based on this value, it will generate PWM output on the PB0 pin to vary the intensity of the LED.

Program
The program is written in Arduino IDE software using C programming language. It is compiled, and a HEX file is created that is downloaded into the internal FLASH of ATtiny85

Program logic
Program logic is very simple. First, ATtiny85 will read analog voltage on analog input pin A2. It will get a value between 0 to 1023. This value will generate PWM output on pin 5 (PB0) by dividing this value by 4. The value is divided by 4 because the PWM value is between 0 to 255, while the input range is 0 to 1023.

In the next tutorial, we shall learn to vary DC motor speed using a potentiometer.

You may also like:


  • ATtiny85 microcontroller tutorials, Part 5: LED intensity control using ATtiny85

  • ATtiny85 microcontroller tutorials, Part 3: Building LED blinking application using…

  • ATtiny85 microcontroller tutorials, Part 4: LED chaser using ATtiny85
  • ATtiny85
    ATtiny85 microcontroller tutorials, Part 1: Introduction

  • ATtiny85 microcontroller tutorials, Part 2: Working with ATtiny85

  • Getting Started with Microcontrollers

Filed Under: Tutorials
Tagged With: Arduino, ATtiny85, LEDs
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.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

  • Does mobility carrier ratio changes with Wn? (0.18um) inverter design
  • DC/DC Converter with wide range input
  • i need an embedded c program that will read a 12 bit memory address from the io pins and output the data to pins from the memory in a 8051 mcontroller
  • Output return loss mismatch
  • DIY Buck Boost Converter using XL6019

RSS Electro-Tech-Online.com Discussions

  • parallel-to-serial problem
  • Back to the old BASIC days
  • Guitar electronics project
  • 12v battery, 18v magic
  • Actin group needed for effective PCB software tutorials

Featured -USB Series

  • Controller Chip Selection for Developing USB Enabled Device (Part 6/6)
  • Signal and Encoding of USB System (Part 5/6)
  • USB Requests and Stages of Control Transfer (Part 4/6)
  • USB Descriptors and their Types (Part 3/6)
  • USB Protocol: Types of USB Packets and USB Transfers (Part 2/6)
  • Introduction to USB: Advantages, Disadvantages and Architecture (Part 1/6)

Recent Articles

  • Littelfuse driver achieves less than 1 µA standby current for energy-efficient designs
  • Microchip optimizes power consumption in transceiver-less FPGA design for automotive applications
  • What is an IoT platform and when is one useful?
  • Silanna launches laser driver IC with sub-2 ns FWHM pulse for LiDAR application
  • LEM introduces current sensors with bandwidth up to 2.5 MHz for precision applications

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

  • Electronics Projects and 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