Introduction: Programmable Pumpkin Light
This Instructable is for making a programmable Pumpkin light with an ATTiny microcontroller. This was designed as a learning demo to introduce anyone (age 8+) into electronics and programming microcontrollers using the Arduino IDE.
- Understanding what an Input is, and what an Output is for a microcontroller.
- Understanding how a microcontroller Output can control an LED.
- Understanding how a Button Input can be read by the microntroller.
- 1 Mini Bread Board
- 1 ATTiny85
- 1 3V coin cell battery
- 1 coin cell battery holder
- 2 33 Ohm resistors (Orange, Orange, Red)
- 1 10 k Ohm resistor
- 1 RGB LED
- 1 sliding switch
- 1 push button
- 8 wires
Step 1: Circuit Diagram
This is the circuit diagram for the Pumpkin LED controller. The LED is controlled by pins 2(red), 1(green), and 0(blue).
The ATTiny turns on the LEDs by pulling the programmed pin down to ground. This is done with the following line of code for the red LED
digitalWrite (redPin, ON);
The button connected to pin 3 of the ATTiny tells the ATTiny when to switch the mode of the LED.
Step 2: Putting the Components on Your Breadboard
The next few steps will instruct you on how to wire up your breadboard. It is IMPORTANT that you wire your board up exactly as shown in the pictures, otherwise your pumpkin light might not work. Please ask for help from a volunteer if you are unsure of anything.
note: the bread board rows on either side of the center-line are connected
Step 3: Put the Push Button on Your Breadboard
Insert the Push Button into the red circled spaces on your bread board
Step 4: Put the RGB LED on Your Breadboar
Put the RGB LED in to the circled spaces on your bread board. It is important to put them in the board exactly as shown here. The long leg should go in the 5th hole from the top.
Step 5: Put the Battery on Your Breadboard
Place the Battery on your board in the circled holes. It must go on the 2nd row from the bottom of your board.
Step 6: Add the Sliding Switch to Your Bread Board
Add the sliding switch as shown in the photo
Step 7: Add the ATTiny85 Microcontroller to Your Bread Board
*Be very careful to not break the legs on your ATTiny microcontroller. It is also important to add it with the little dot in the upper left corner (circled in white) as show on the photo. Don't push the microcontroller all the way in since we will be removing it to program it later.
Step 8: Wire the Red LED to Pin 2 of the ATTiny85
Put a wire in the holes shown in the photo.
Note* The color of the wire does not matter, but it is helpful to use different collors to make it easier to see what is connected.
Step 9: Wire the Green LED to Pin 1 of the ATTiny85
Wire the pin as shown in the picture
Step 10: Wire the Blue LED to Pin 0 of the ATTiny85
Add the wire connecting the Blue LED leg to pin 0 of the ATTiny as shown in the picture
Step 11: Wire the ATTiny + Pin to Power
Step 12: Connect the 33 Ohm Resistor Fromt the LED + Leg to Power
The resistor with the Orange, Orange, Black, bands is the 33 Ohm resistor.
Step 13: Connect Add a 33 Ohm Resitor Between Power and the Button
The resistor with the Orange, Orange, Black bands is the 33 Ohm resistor.
Step 14: Wire the Slide Swith to +3V
To make this step easier you can remove your battery cell holder to put the wire in the correct holes.
Step 15: Wire the (-) Pin of the ATTiny to Ground
Step 16: Add a 10K Resistor Betweent Button and Ground
Add the 10 K ohm resistor (Brown, Black, Orange) between the ground and the button.
Step 17: Wire the Bottom Leg of the Button to Pin 3 on Your ATTiny
Step 18: Develop Your CODE
- Download the code
- Edit the code
This is a STATE driven code. Meaning that the STATE (which are typed in CAPS in the code eg RED_STATE).
To add a state you must declare it at the top of the code, and update the number of states.
Then you can modify the Switch case to include your new STATE.
Step 19: Configure the Arduino IDE to Program the ATTiny
- >Tools > Board select the ATTiny85 1 MHz clock
- >Tools>Programmer> USBtinyISP
Step 20: Program the ATTiny and Connect Your Bread Board to the AVR Programer
- Remove the ATTiny from your bread board and put it in the AVR Programmer. Your must plug it into the board with the little dot in the upper left corner as shown in the first picture.
- Take 3 wires and connect pins 2,1,0 on the programmer to the corresponding pins on your bread board. See photos for details.
- Take one wire wire and connect pins (-) on the programmer to the corresponding ground on your bread board. See photos for details.
- load the Arduino code on to the ATTiny by selecting the upload arrow in your Arduino IDE (If you get an error that when uploading the code see the previous step)
Step 21: DONE!
If your code is working as you want it too. Remove the flexible wires from your bread boar and place the ATTiny programmer in your bread board .
BEFORE you light up your Pumpkin, place the circuit in a plastic bag to protect it from shorting if any pumpkin goop falls on it.
VickyR made it!
We have a be nice policy.
Please be positive and constructive.