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
  • 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

  • Adjustable 0 to 30V 2A DC Power Supply Circuit (Part 1/13)
  • Adjustable +/- 1.25V to +/-22V 1A Power Supply Circuit (Part 2/13)
  • Adjustable 0 to 15V 1A Mini Power Supply (Part 3/13)
  • Constant 12V Power Supply for LED Circuits (Part 4/13)
  • Constant +/-9V DC Symmetrical Power Supply Circuit (Part 5/13)
  • Making a Circuit Breaker (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

“ee

“ee

“ee

“ee

“ee

Recent Articles

  • Infineon offers Press Pack IGBT for transmission and distribution applications
  • STMicroelectronics outlines path to $20B+ revenue
  • STMicroelectronics and MACOM announce successful RF GaN-on-Si prototypes
  • Infineon expands its CoolSiC portfolio
  • STMicroelectronics and AWS collaborate for secure IoT connections

Most Popular

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

RSS EDABOARD.com Discussions

  • Space Vector PWM Help Needed
  • RFIC LNA cascode base and ground layout problem
  • Unable to launch virtuoso: libvisadev.so error
  • DIY test leads - source for lead ends?
  • P-Channel MOSFET always on

RSS Electro-Tech-Online.com Discussions

  • Voltage Regulator 12 - 5volt
  • How do I test amplifier speaker output polarity?
  • Adding Current Limit Feature to a Buck Converter
  • How to get lots of PCBs made cheap?
  • 24v dc relays not de-energising
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
  • Women in Engineering