Microcontroller

USB RGB LED Controller Based on AVR Microcontroller

Why not upgrade the CPU usage LED project to a general-purpose RGB LED controller? The current CPU usage LED controller uses a value between 0 and 255 to calculate the color it should be and then fades to that color. This is indeed quite limited; changing the color and fading method requires firmware updates. In contrast, a general-purpose RGB LED controller can let the host software handle all the work, and the controller only needs to be told what brightness the red, green, and blue LEDs should be, providing greater flexibility and scalability.

To simplify interactions with the controller, I developed a library that wraps all LibUSB content. With this library, you can achieve basic functionality with just a few lines of code (only 10 lines).


#include <rgbledctrl.h> int main() { rgbledctrl_init(); rgbledctrl_find(); s_rgbled_device* rgbLed = rgbledctrl_open(); rgbledctrl_setR(rgbLed, 200); // Set red value to 200 rgbledctrl_close(rgbLed); return 0; }

The library also has support for reading and writing to the EEPROM of the controller. Class wrappers for C++ and C# .NET are also provided.

Download from GitHub
Documentation

Microcontroller PWM Controller: A Design Based on ATtiny25 and MOSFET

I recently designed a PWM controller based on a microcontroller and MOSFET, which can control high-current loads. It’s a bit like a PWM controller based on a 555 timer, but now using a microcontroller and MOSFET instead of a 555 IC and transistor.

I made two versions, one with acceleration and deceleration switches, and another with a potentiometer. The controller uses an ATtiny25 microcontroller, running at 31.25KHz (8MHz internal RC/256 prescaler), powered by 3.3V. I used an STP36NF06L MOSFET, with a maximum 0.045Rds and 2.5Vgs, which is suitable for 3.3V power supply. The MOSFET produces only ~180mW of heat at 2A, which doesn’t require a heat sink.

In the circuit diagram, if using a 5V power supply, R1 should be changed from 100R to 150R to keep the current below 40mA. Zener diodes D1 and D2 are used for ESD protection, requiring a voltage rating above the uC power supply voltage and below the maximum gate voltage of the MOSFET. The STP36NF06L MOSFET can easily switch ~8A, but requires some heat sinks. The potentiometer selection also needs to consider the microcontroller ADC reading and current consumption.

Update – July 10, 2013

I recently designed a new …