AdSense

Monday, 17 February 2014

Control LED strip with ATmega / Arduino

(Deutsche Version) LED strips have been gaining more and more popularity within the last few years. There are even LED strips for less than 20 euro from china. Usually, an LED strip consists of a control unit, a power supply and a remote. For most people, this is sufficient. Anyone who wants to have more (e.g. run through sequences) has to put in a little effort.

Let's primarily face the structure of the strip. There are four connections, one of them is for the + 12 V power supply, the other three connections are for the individual colours. The strip is working like this: If you apply + 12 V and then connect ground to one of the colour connections, this colour is shining. The brightness is now controlled vie PWM. To fully control the LED strip you need:
  • A microcontroller (ATmega / Arduino)
  • 3 bipolar transistors (NPN) which can handle enough current!
The microcontroller sends 3 PWM signals to the base of the transistors (apply pre-resistors, I use 470 Ohms). The emitter of the transistors is connected to ground (a common ground of the 12 V power supply and the microcontroller), the collector is connected to the corresponding colour channel.

To control a single color, you have to execute:


analogWrite(8, 127);

This command will set the transistor which is connected to pin 8 to 50% (255 is the maximum), so the connected colour has 50% brightness. You can only use PWM channels for this (in the data sheet usually referred as OCR).


To achieve any color, you have to mix the colors. therefore, you have to choose a colour in the RGB space, e.g. orange: this colour is R: 255, G:255, B:0. Now you have to program this into the microcontroller:


analogWrite(RED_PIN, 255);
analogWrite(GREEN_PIN, 255);
analogWrite(BLUE_PIN, 0);  

It could occur that different colours are seen at different brightness, you should test this and then set the maximum limit e.g. for green to 127 (green appears very bright for the human eye, therefore the green colour could be too bright.

1 comment:

  1. what is led lighting system and how is working. Please visit us for learn more details aboit us and led lighting-EXTRUSION FOR LED STRIPS
    Welcome to
    Prisma Led Store
    Shamim

    ReplyDelete