Monday, December 26, 2016

LED strip lights gradual fader




 

This LED fader circuit requires a Arduino device and a LED strip tape that is RGB colored. The photo on the side shows the cluttered breadboard holding the Arduino nano, mosfets and the LM7805 regulator. It is recommended to solder the components and solder a socket for the Arduino Nano onto a PCB board to maintain proper electrical connect. Typical application for this light circuit are Christmas Lights (which this was used for) and indoor house light decorations. The LED tape used here is a 5 metre roll of 5050 LED lights which was powered by a 12V 3 Amp power supply. The Arduino code cycles through many colors and the rate of change can be changed by changing the delay value in the code.
  The following picture shows the entire circuit diagram: 

Below is the Arduino Code that I found:

Change the integers of the orange highlighted part to change the pinouts of the Arduino
Change the integers of the yellow highlighted part to change the changes of color pattern
Change the integer of the turquoise highlighted part to change the speed of change

const int redled = 11;
const int greenled = 10;
const int blueled = 9;

void setup() {
  setColourRgb(0,0,0);
}

void loop() {
  unsigned int rgbColour[3];

  rgbColour[0] = 0;
  rgbColour[1] = 0;
  rgbColour[2] = 0;

for (int decColour = 0; decColour < 3; decColour += 1) {
int incColour = decColour == 2 ? 0 : decColour + 1;
    for(int i = 0; i < 255; i += 1) {
      rgbColour[decColour] -= 1;
      rgbColour[incColour] += 1;
   
      setColourRgb(rgbColour[0], rgbColour[1], rgbColour[2]);
      delay(20);
    }
  }
}

void setColourRgb(unsigned int red, unsigned int green, unsigned int blue) {
  analogWrite(redled, red);
  analogWrite(greenled, green);
  analogWrite(blueled, blue);

 }