ATtiny85 RGB LED Control: Addressable RGB LEDs with ATtiny85

Published By

Addressable RGB and RGBW LEDs like the famous WS2812B allow engineers to apply fantastic lighting effects on a limited budget. We explored this interesting protocol in some detail, but if you want to get things "lit," you can use the Adafruit NeoPixel library.

The NeoPixel library works well on Arduino and Adafruit boards, but what about the humble ATtiny85? Can this little chip run a bank of programmable LEDs by itself? The short answer is "yes," however, you'll need to make a few changes to get your ATtiny85 working properly.

Programming ATtiny85 RGB LED with Arduino


RGB LEDs_IMAGE 2


To get started, follow these steps:

1. Install the Adafruit NeoPixel library on the Arduino IDE, which is generally a matter of performing a search and installation via the Library Manager (through the menus or Ctrl + Shift + I)

2. Load an included example—we'll use 'strandtest' here—customizing options like the number of LEDs and which pin actually controls the chain of RGB LED modules

3. For the ATtiny85, set up the Arduino IDE (if you haven't already). Note that the chip's physical pins won't be numbered in the same way as they are in the Arduino IDE, so use this diagram for reference. If you only need one pin for LED control, Arduino IDE pin 0 (physical pin 5) is in the opposite corner of the chip's dot

4. Under 'Tools,' set the board to 'ATtiny25/45/85,' and the processor to ATtiny85

5. Select 'Internal 8 MHz' for the clock speed, as this library doesn't work at its factory settings

6. With the ATtiny85 and programmer connected, hit 'Burn Bootloader' to instruct the chip to run at this speed

A 16 MHz clock may also work, but we did not include one in our testing. Also note that depending on which LEDs you use, you may have to change some other options.


RGB LEDs_IMAGE 3-min 1


Upload and Go!

Upload the modified example code using a programmer. Connect your power and ground leads to the voltage supply and connect the signal input to the pin you assigned on the ATtiny85. With everything correctly connected, you'll see a variety of changing colors and have an extremely compact setup to control one or more addressable LEDs.

 

ATtiny85 Programming in PlatformIO

If you're using PlatformIO, as introduced here using Visual Studio Code, you can also program the ATtiny85 using this IDE. While I won't go through a step-by-step tutorial on the subject, you can review a basic piece of example code that works with it. In order to run the code, you'll need the proper library and the ATtiny85 needs to be set to run 8 MHz. I used the Arduino IDE to set the clock speed.

Finally, modify the platformio.ini file to suit your chip. You can see the configuration that worked for me in the image below:


RGB LEDs_IMAGE 4

Need an Arduino? Shop all of our Arduino products here

Latest News

Sorry, your filter selection returned no results.

We've updated our privacy policy. Please take a moment to review these changes. By clicking I Agree to Arrow Electronics Terms Of Use  and have read and understand the Privacy Policy and Cookie Policy.

Our website places cookies on your device to improve your experience and to improve our site. Read more about the cookies we use and how to disable them here. Cookies and tracking technologies may be used for marketing purposes.
By clicking “Accept”, you are consenting to placement of cookies on your device and to our use of tracking technologies. Click “Read More” below for more information and instructions on how to disable cookies and tracking technologies. While acceptance of cookies and tracking technologies is voluntary, disabling them may result in the website not working properly, and certain advertisements may be less relevant to you.
We respect your privacy. Read our privacy policy here