Control many RGBs with AVR XMEGA microcontroller & Fade effect tutorial

Timer configuration

Let’s write a simple codebase to control 8 PWM channels. I’ll use a real world example — I’ve done this configuration in my room. It has two RGB strips and two single color LEDs:

  • Bed RGB — RGB strip over my bed
  • Window RGB
  • Desk white LED
  • Bookshelf white LED

Adding fade effect

Now we’re going to add a simple fade effect. It will let us go smoothly from one color to another. I have done it using C++ features.
Firstly, let’s create a pair of files: header LedController.hand source LedController.cpp. Here’s the first one:



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Bartłomiej Klocek

Bartłomiej Klocek

Enthusiast of electronics and all kinds of software development — from web apps to embedded systems. Expo open-source contributor at Software Mansion.