Introduction: ATtiny85 Color Mix Light

Led lights that can mix two colors together. It doesn't require dual color LEDs.

Step 1: Gathering Components

I used the following materials to create the light:

  • x1 12V power supply - (should only need 500mA but I used an 800mA supply)
  • x1 ATtiny85 chip - (Any Arduino board can be used if the code is edited )
  • x1 5v voltage regulator - (this will step the 12v down to 5v to power the Arduino board
  • x2 different colored led strips - (I used red and blue)
  • x2 N-Channel Mosfets - (I used IRFZ44N's to control the LED strips)
  • A good length of 22 gauge wire
  • x1 breadboard - (I can't solder on a protoboard)
  • x1 pushbutton - (this will allow the circuit to enter the 4 different modes)
  • x2 8.5 kilo-ohm resistors - (these will protect the MOSFETs from turning on when they shouldn't

Tools I used:

  • Multimeter - wins for being the most used tool
  • Wire Strippers
  • Wire Cutters
  • Cardboard Cutter or a Dremel
  • Alligator Clips
  • Soldering essentials (Iron, flux, solder)
  • Electrical Tape

The final things you will need are two tubes. One tube should be larger, and the larger one should also have a lot of white on the inside. I had a cardboard tube and clear tube at hand. Lucky for me my large cardboard tube had a white inside. You can always use sheets of paper to allow the light to reflect more inside.

Step 2: Setting Up the Power Supply

I always solder 22 gauge wire to the power supplies with color coding. Oftentimes there are markings on the wires already that show the polarity. Just to be sure, I always use a multimeter to check polarity.

Once you know the polarity, solder wires the wires together and make sure they get a strong connection. Now insulate the wires using electrical tape. The power supply is ready.

Step 3: Test the 5V Regulator

Insert the 5v regulator like so. Connect pin 1 to the +V row and pin 2 to the ground row. Insert a wire in the ground row and another on the same row as pin 3. Get out the multimeter and have it ready to test for a dc voltage. Plug in the wires of the power supply in the corresponding rows (+12 to the red, and ground to the blue row). Now plug in the supply to an outlet. The multimeter should give a reading of 5V or very close. If not, check your connections. If the connections are right, try another regulator.

Step 4: Get the MOSFETs Ready

Before you continue, you should disconnect power to the 5v regulator. You don't want to short a good supply on accident. Insert the two MOSFETs like so and then connect them like this. Connect pin 2 of each MOSFET to a ground of a LED strip. Now connect the third pin to ground. The first pin I haven't mentioned yet is what controls the MOSFET. If it is connected to a positive voltage, MOSFET pins 2 and 3 become connected. Otherwise, there is no connection. What you want to do is connect the 8.5 kilo-ohm resistor from pin 1 to the +V row of the breadboard. Finally, make sure the positive parts of the led strips are connected to the +V row as well. It should look something like this. See if your led strips have built-in resistors. Don't do this next step if they don't. Connect the power and see the full brightness of the LED strips.

Step 5: Program the Arduino

Before inserting the microcontroller into the circuit, it's a good idea to have it already programmed.

Hopefully, the code is explained well enough for anyone to edit to their needs.

static int led1 = 0;

static int led2 = 1;

int wait = 500;

int buttonPin = 2;

int buttonState;

int mode = 0;

void setup() {

pinMode(led1, OUTPUT);

pinMode(led2, OUTPUT);

pinMode(buttonPin, INPUT);

}

void loop() {

buttonState = digitalRead (buttonPin);

if (buttonState == HIGH) {

mode++;

delay(500);

}

if (mode > 4) {

mode = 1;

}

switch (mode) {

case 1: one(); break;

case 2: two(); break;

case 3: three(); break;

case 4: off(); break;

}

}

//make sure

void one() {

digitalWrite(led1, HIGH);

digitalWrite(led2, LOW);

}

void two() {

digitalWrite(led1,LOW);

digitalWrite(led2, HIGH);

}

void three() {

digitalWrite(led1, HIGH);

digitalWrite(led2, HIGH);

}

void off() {

digitalWrite(led1, LOW);

digitalWrite(led2, LOW);

}

Step 6: Insert the Microcontroller and Resistors

Place the ATtiny85 chip so that pin 8 is on the same row as pin 3 of the voltage regulator. You can check where pin one is by looking for a little dot on the chip. It indicates where pin one is.

Now connect an 8.5 kilo-ohm resistor from pin 6 to ground and another resistor from pin 5 to ground. It should look something like this. Connect a wire from pin 4 to ground.

Step 7: Connect the MOSFETs to the Microcontroller

Now that pins 5 and 6 have resistors going to grouind, it is time to connect them to MOSFETs. Connect pin 5 of the chip to pin 1 of the MOSFET (the gate) with a wire. Connect pin 6 of the chip to pin 1 of the other MOSFET with a wire as well.

Step 8: Add a Button

In order to control which mode the circuit is in, we use a counter in the code that counts how many times a pin has gone HIGH. For this, I will use a pushbutton. Insert the button near the microController. One side of the switch should have an 8.5k resistor to ground. The other side of the switch should be directly connected the +V row. Finally, a wire should connect pin 7 of the controller chip to the side of the switch that had a resistor going to ground. All that should be left to do is to add power.

Step 9: Give It Power

Connect the power to the circuit. Do not get frustrated if there is no light when you apply power. The code makes the default mode off. I would suggest holding down the button so it screens through all 4 of the modes. You should see off, one color, another color, and then both mixed.

If you are like me and have quite a collection of electronics, do not mistake a voltage regulator as a MOSFET. When I first powered on my circuit I was scratching my head until I realized the writing was not the same on them. It was in my drawer labeled MOSFET when I picked it up so I don't how it got there.

Step 10: Make a Case

Like I mentioned in the beginning, I just used some carboard for my enclosure. I just wanted to share the circuit for this project. As long as the inside contains a reflective inside, the colors should mix well. Try to make the holes for the light to escape not right next to the led strips. It can mess up the color balance.

Comments

author
Swansong made it! (author)2017-01-26

That would make a fun night light :)

About This Instructable

141views

3favorites

License:

More by Shadowmage1:ATtiny85 Color Mix Light
Add instructable to: