Introduction: AtTiny45 Controlled, 3D-printed Christmas Tree (TfCD Assignment)
In this tutorial, we explain how to use a AtTiny45 to make a christmas tree with lights that turn on when night falls. The advantage of the AtTiny is that they are small and cheap boards, so they fit in a small product and you don't have to sacrifice a whole arduino.
For this tutorial you need:
3 AA batteries
2 150 ohm resistors to connect to the leds
1 330 ohm resistor to connect to the transistor
1 10k Ohm resistor to connect to the ldr
Step 1: Prepare the Arduino IDE for ATtiny
Open the Arduino IDE. First make sure you make connection with your Arduino Uno. Then, you need to specify that you will need the Arduino to transfer data to the ATtiny. Go to File > Preferences. Copy the following url and place it after "Additional Boards Managers URL's": https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json and click OK.
Go to Tools > Boards > Board Manager. When you scroll down you will find ATtiny in the title. Install it and close the window.
When you go to Tools > Board, you can now select ATtiny 25/24/85.
Select ATtiny45 at Tools > Processor.
And select that you are going to use the Arduino as "in-system-programmer (ISP)" under Tools > Programmer.
Step 2: Connect the ATtiny to the Arduino
Connect the ATtiny to the Arduino as can be seen in the picture above.In this orientation the small hole on the ATtiny should be on the down left corner.
The wires connect to the GND, 5V and port 10, 11, 12, 13
Step 3: Type the Code
The ATtiny does not have a lot of storage space. Therefor it can only run small programs. Fortunately, the code needed for controlling the lights with an ldr is very small and simple. The code can be seen in the picture. You can type it over, or write your own.
Step 4: Make the Circuit
Connect the circuit on a breadboard to test it with the written code. As you can see there are two output ports going to transistors. This could also with one port and one transistor, but two allows for adding different interactions for different lights, which could be nice to add in the code.
We forgot to include a switch, which comes in convenient, if you want to store it for next year.
Step 5: Solder the Circuit
After testing the circuit on a breadboard, solder everything together in the same order. Make sure you add some wires where needed, so the sensor can be placed in the top of the tree and the leds in the branches.
Solder three AA batteries together in series. This results in a 4.5 volt DC voltage source.
Tape the wires or use shrink sleeves so it does not make a short circuit.
Also important, don't place it on a steel table or in a steel bucket, when the wires and batteries are not yet protected. We transported the circuit in a tin paint can, which we will not do again.
Step 6: 3D-print the Christmas Tree
3D-Print it with the setting you prefer. In the pictures, our settings can be seen for an Ultimaker 2.
Step 7: Assemble the Tree
Now you have everything to assemble the Christmas Tree. Clean the print, by taking away the support material. Install everything in the top part. The leds may be hard to reach, but it is doable. Bring the parts together by dropping the batteries in the lower part and screw the parts together.
Congratulations, you made your own miniature christmas tree.
We have a be nice policy.
Please be positive and constructive.