Introduction: Turning on LED Strips for Christmas!

Make a 12V LED strip that turns on colors of red, green, blue, magenta, cyan, yellow, and white and then make red, green, and blue go from low dimness to high dimness!

Why are we doing all this JUST to turn on a 12V LED strip???
A transistor is a semiconductor device with three connections, capable of amplifying the voltage of the current in addition to (reducing) it. The reason we are using a transistor to turn on the 12V LED strip is because the current from the Arduino is not enough to power the 12V LED strip on its own, as Arduinos can only power electronics with 5Vs. However using a transistor, we can "amplify" the amount of current that an Arduino can access. Through this transistor, a 12V current can travel along from the 5V Arduino through a strip from a 12V external power source, and thus, we are able to turn on 12V LED strip through a 5V Arduino using a 12V transformer from a 220V outlet.

Step 1: Grabbing the Materials

You will need:

1. 12V RGB LED strip

2. Arduino Uno

3. Laptop w/Arduino software

4. Breadboard

5. 16 male-male jumper wires

6. 2 male-female jumper wires

7. 3 2N2222 transistors (NPN)

8. 3 240ohm resistors

9. External plug source to 12V transformer plug

10. Barrel plug adapters

11. 2 functioning LEDs

12. 1K resistor

13. 1 390ohm resistor

Step 2: Testing Every Material to Make Sure That the Entire Product Works Part 1

Testing the Arduino to make sure it works:

1. Plug Arduino into your laptop

2. Open the Arduino software

3. Go to File then Examples then 01. Basics and then Blink

4. Upload the program onto the Arduino (if there is a problem, double check the tools-port and make sure it connects to usbmodem.

5. If the light in "L" is blinking, then programming for the Arduino and the Arduino Uno hardware works. Once these things are working proceed to the next step. If the Arduino does not work, replace the Arduino.

Basic Arduino knowledge: turning on the LEDs

1. As a prerequisite to learning how to turn on a 12V LED strip, we first need to turn on an LED to double check that the resistor and the Arduino works. Wire the LEDs accordingly in the images section to test the LED so that we know for sure that the functions of the Arduino works. If the LED doesn't work, replace the LED.

2. Copy the following code for testing the LED:

void setup() {
// put your setup code here, to run once:

pinMode(13, OUTPUT);

}

void loop() {

// put your main code here, to run repeatedly:

digitalWrite(13, HIGH);

delay(1000);

digitalWrite(13, LOW);

delay(1000);

}

Testing the 2N2222 transistors to make sure they work:

1. Plug the transistor so that it faces you and then set up to test the transistors according to the pictures. Make sure that the longer side of the LED connects to the 390 resistor

2. Copy the following code for testing the transistor (or use a previous code for the LEDs since they both have the same functions as each other):

3. Test three transistors for the 12V LED strip task by taking one transistor and replacing it with another one in the same fashion as the previous transistor.

void setup() {
// put your setup code here, to run once:

pinMode(13, OUTPUT);

}

void loop() {

// put your main code here, to run repeatedly:

digitalWrite(13, HIGH);

delay(1000);

digitalWrite(13, LOW);

delay(1000);

}

Testing the barrel plug adapter:

1. Plug the barrel plug adapter to the external plug source connecting the 12V transformer to see if the barrel plug adapter works. If the barrel plug adapter turns red, then the barrel plug adapter works.

Step 3: Testing Every Material to Make Sure That the Entire Product Works Part 2

Basic Arduino knowledge: turning on the LEDs

1. As a prerequisite to learning how to turn on a 12V LED strip, we first need to turn on an LED to double check that the resistor and the Arduino works. Wire the LEDs accordingly in the images section to test the LED so that we know for sure that the functions of the Arduino works. If the LED doesn't work, replace the LED.

2. Copy the following code for testing the LED:

void setup() {

// put your setup code here, to run once:

pinMode(13, OUTPUT);

}

void loop() {

// put your main code here, to run repeatedly:

digitalWrite(13, HIGH);

delay(1000);

digitalWrite(13, LOW);

delay(1000);

}

Step 4: Testing Every Material to Make Sure That the Entire Product Works Part 3

Step 5: Wiring for the LED Strip

REFER TO PICTURES FOR ANY CLARIFICATIONS NEEDED

Step 3.1 (setting up the breadboard)-

1. Set up the transistors so that the flat sides are facing the left side of the breadboard and are parallel to the numbered rows of the breadboard, accordingly. Plug the first transistor into the breadboard so that it fits in holes i2, i4, and i6. Plug the second transistor so that it fits in holes i13, i15, and i17. Plug the third transistor so that it fits in holes i25, i27, and i29.

2. Place the resistors (which side (red strip of the resistor or brown strip of the resistor) you place them does not matter) so that it connects parallel to the base of the transistor (middle of the transistor).

3. Take two male-female wires. Connect one to the positive side of the barrel plug adapter and connect the other one to the negative side of the barrel plug adapter.

4. Connect the positive male-female wire to the positive side of the breadboard (as shown in the white wire) and the negative male-female wire to the negative side of the breadboard (as shown in the blue wire).

Step 3.2 (Red lights)-

1. Using the short red jumper wire, connect one side to the red wire on the LED strip and the other to the collector side (right side) of the first 2N2222 transistor on h6.

2. Take another short jumper wire and connect one side to the emitter side of the transistor (left) and then the other side to the negative side of the breadboard where you connected the male-female external plug on h2.

3. Using another short jumper wire, connect one side to the resistor and the other side to Arduino pin 3.

Step 3.3 (Green lights)-

1. Using the short green jumper wire, connect one side to the green wire on the LED strip and the other to the collector side (right side) of the second 2N2222 transistor on h17.
2. Take another short jumper wire and connect one side to the emitter side of the transistor (left) and then the other side to the negative side of the breadboard where you connected the male-female external plug on h13.
3. Using another short jumper wire, connect one side to the resistor and the other side to Arduino pin 5.

Step 3.4 (Blue lights)-

1. Using the short blue jumper wire, connect one side to the blue wire on the LED strip and the other to the collector side (right side) of the third 2N2222 transistor on h29.
2. Take another short jumper wire and connect one side to the emitter side of the transistor (left) and then the other side to the negative side of the breadboard where you connected the male-female external plug on h25.

3. Using another short jumper wire, connect one side to the resistor and the other side to Arduino pin 6.

Step 3.5 (VCC positive for the 12V LED strip and GND)

1. Using the short jumper wire (color does not matter here), connect one side to the white LED port and the other to the positive side of the breadboard.

2. Using a short jumper wire connect one side to the negative side of the breadboard and the other to the GND of the Arduino.

Step 6: Coding for the LED Strip

1. Copy the following code to the Arduino software for the 12V LED strip so that it turns on Red, Green, and Blue accordingly and then Magenta, Cyan, Yellow and White and then turn RGB lights with dimness:

void setup() {
// put your setup code here, to run once:

pinMode(3, OUTPUT);

pinMode(5, OUTPUT);

pinMode(6, OUTPUT);

}

void loop() {

// put your main code here, to run repeatedly:

digitalWrite(3, HIGH); //Red

delay(1000);

digitalWrite(3, LOW);

digitalWrite(5, HIGH); //Green

delay(1000);

digitalWrite(5, LOW);

digitalWrite(6, HIGH); //Blue

delay(1000);

digitalWrite(6, LOW);

//Magenta

digitalWrite(3, HIGH);

digitalWrite(6, HIGH);

delay(1000);

digitalWrite(3, LOW);

digitalWrite(6, LOW);

//Cyan

digitalWrite(5, HIGH);

digitalWrite(6, HIGH);

delay(1000);

digitalWrite(5, LOW);

digitalWrite(6, LOW);

//Yellow

digitalWrite(3, HIGH);

digitalWrite(5, HIGH);

delay(1000);

digitalWrite(3, LOW);

digitalWrite(5, LOW);

//White

digitalWrite(3, HIGH);

digitalWrite(5, HIGH);

digitalWrite(6, HIGH);

delay(1000);

digitalWrite(3, LOW);

digitalWrite(5, LOW);

digitalWrite(6, LOW);

//Lights with dimness

//Red with dimness

for(int i=10; i<255; i++)

{ analogWrite(3,i); delay(50); }//end of fade loop

digitalWrite (3,LOW);

delay (1000);

}

//Green with dimness

for(int i=10; i<255; i++)

{ analogWrite(5,i); delay(50); }//end of fade loop

digitalWrite (5,LOW);

delay (1000);

}

//Blue with dimness

for(int i=10; i<255; i++)

{ analogWrite(6,i); delay(50); }//end of fade loop

digitalWrite (6,LOW);

delay (1000);

}

Step 7: Testing

1. Upload the code on the Arduino (if there are problems connecting to the port to upload the program, go to tools and then port and then reconnect to the usbmodem so that it is functional.

2. Then, plug in the external plug source to 12V transformer plug to a power outlet to turn on the LED strip!

Arduino Contest 2017

Participated in the
Arduino Contest 2017