Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key 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
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering

Tutorial 8: RGB LED interfacing with ATtiny85

By Ashutosh Bhatt

In the previous three tutorials of this series, we saw how to vary the intensity (brightness) of LED and DC motor speed using the PWM output of ATtiny85.

In all those previous tutorials, we used only one PWM output, but now we shall simultaneously use three PWM outputs of ATtiny85. ATtiny85 has three PWM outputs on pins 3 (PB4), 5 (PB0), and 6 (PB1). These three PWM outputs vary the intensity of red, green, and blue LEDs of RGB LED. We can generate many different colors from RGB LED by varying the intensity of all three red, green, and blue LEDs. Let’s see how it is done.

If you are not following this tutorial series from the beginning, then you should go through the following two tutorials that explain and demonstrate how to work with ATtiny85 and a 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 three components RGB LED, 220-ohm resistors, and ATtiny85. RGB LED is used that is of common cathode type. Its red anode is connected with pin PB0 (pin 1), the blue anode is connected with pin PB1 (pin 2), and the green anode is connected with pin PB4 (pin 3). One 220Ω resistor is connected to each anode to limit the current. The cathode of the LED is connected to pin 4 that is connected to ground. A 5 V supply is given to the Vcc pin (8).

Circuit operation
ATtiny85 will generate PWM output on pins PB0, PB1, and PB4. This will vary the intensity of red, blue, and green LEDs. When the intensity of red, green, and blue LED is varied, it will change the proportion of red, green, and blue color from 0 – 100 percent, creating different colors. For example, by applying PWM to red and green LEDs and varying their proportions, we can generate different colors and shades of red, green, yellow, and orange colors.

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

Program logic
The program generates PWM on all three pins PB0, PB1, and PB4.

Firstly, it will turn OFF the green LED by making its intensity 0 and make the red LED fully bright. Then it varies the brightness of the blue LED from minimum to maximum. This will generate different shades and colors of pink and magenta and then change the brightness of red LED from minimum to maximum. Again this will yield different colors and shades of light blue and dark blue colors.

Thus the program will turn ON one LED fully, turn OFF the other LED, and vary the intensity of the third LED. This will generate very nice and eye-catching colors and shades.

The program will start varying the intensity of two colors together like red+green, green+blue, and red+blue. So this will also create so many different colors and shades.

In the next tutorial, we shall learn to interface Bluetooth module HC05 with ATtiny85.

You may also like:


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

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

  • Tutorial 7: DC motor speed control using ATtiny85

  • Tutorial 9: Device control using smart phone’s Bluetooth and ATtiny85

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

  • ATtiny85 microcontroller tutorials, Part 2: Working with ATtiny85

Filed Under: Tutorials
Tagged With: ATtiny85, pwm
 

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.

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!


Featured Tutorials

  • Introduction to Brain Waves & its Types (Part 1/13)
  • Understanding NeuroSky EEG Chip in Detail (Part 2/13)
  • Performing Experiments with Brainwaves (Part 3/13)
  • Amplification of EEG Signal and Interfacing with Arduino (Part 4/13)
  • Controlling Led brightness using Meditation and attention level (Part 5/13)
  • Control Motor’s Speed using Meditation and Attention Level of Brain (Part 6/13)

Stay Up To Date

Newsletter Signup

Sign up and receive our weekly newsletter for latest Tech articles, Electronics Projects, Tutorial series and other insightful tech content.

EE Training Center Classrooms

EE Classrooms

Recent Articles

  • What are the battery-selection criteria for low-power design?
  • Key factors to optimize power consumption in an embedded device
  • EdgeLock A5000 Secure Authenticator
  • How to interface a DS18B20 temperature sensor with MicroPython’s Onewire driver
  • Introduction to Brain Waves & its Types (Part 1/13)

Most Popular

5G 555 timer circuit 8051 ai Arduino atmega16 automotive avr bluetooth dc motor display Electronic Part Electronic Parts Fujitsu ic infineontechnologies integratedcircuit Intel IoT ir lcd led maximintegratedproducts microchip microchiptechnology Microchip Technology microcontroller microcontrollers mosfet motor powermanagement Raspberry Pi remote renesaselectronics renesaselectronicscorporation Research samsung semiconductor sensor software STMicroelectronics switch Technology vishayintertechnology wireless

RSS EDABOARD.com Discussions

  • Pull up via GPIO
  • Variable Phase shift control circuit for PWM circuit
  • Fpga wake up
  • Vco cadencd
  • Thyristor Gate Drive

RSS Electro-Tech-Online.com Discussions

  • DIY bluetooth speaker
  • Question about ultrasonic mist maker
  • HV Diodes
  • Disabled son needs advice please
  • RF modules which can handle high number of bytes per second
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2022 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 | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key 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
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering