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.

Leaning Objectives:

  1. Understanding what an Input is, and what an Output is for a microcontroller.
  2. Understanding how a microcontroller Output can control an LED.
  3. Understanding how a Button Input can be read by the microntroller.

Parts Needed:

  1. 1 Mini Bread Board
  2. 1 ATTiny85
  3. 1 3V coin cell battery
  4. 1 coin cell battery holder
  5. 1 330 Ohm resistors (Orange, Orange, Red)
  6. 1 10 k Ohm resistor
  7. 1 RGB LED
  8. 1 sliding switch
  9. 1 push button
  10. 8 wires
  11. 1 Piezzo Buzzer

Tools Needed:

  1. A Computer with the Arduino Software
  2. An AVR programer (We used Sparkfuns Tiny AVR Prorgrammer but if you already have an Arduino you can follow these instructions to program the ATTiny85 with your arduino)
  3. For this code to work you must use Dr. Azzy's ATTiny Board found here: https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json (Directions on how to install are provided in Step 20)
  4. The RTTL library found here: https://github.com/cefn/non-blocking-rtttl-arduino/blob/master/README.md (Directions on how to install are provided in Step 21)

Step 1: 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 2: Put the Push Button on Your Breadboard

Insert the Push Button into the red circled spaces on your bread board

Step 3: 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 4: Put the ATTINY85 on Your Breadboard

Place your ATTINY 85 in the middle from rows 8 to rows 11. Make sure that the little dot is in the upper left.

*Be very careful to not break the legs on your ATTINY85 microcontroller. You Don't push the microcontroller all the way in since we will be removing it to program it later.

Step 5: 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

Note* The color of the wire does not matter, but it is helpful to use different colors to make it easier to see what is connected.

Step 6: Wire the Green LED to Pin 1 of the ATTiny85

Wire the pin as shown in the picture

Step 7: 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 8: Wire the Power Side of the Button

Add the longer (0.75in) black wire as shown in the picture

Step 9: Wire the Ground Leg of the RGB LED

Add the 330 ohm resistor (orange-orange-brown-gold) as shown in the diagram.

Step 10: Wire Power on ATTiny

Step 11: Add the Slide Switch to the Bread Board

Add the sliding switch as shown in the photo.

Step 12: Put the 3V Coin Cell Battery in the Battery Holder

Do this before putting the Coin Cell Battery holder into the bread board.

Step 13: Add the Coin Cell Batter to the Bread Board

Add this in the exact holes as shown. Make sure the positive terminal is on the right hand side.

Step 14: Wire the Slide Swith to +3V

This is easier if you bend the yellow wire in half first as shown in the picture on the left.

Step 15: Wire the (-) Pin of the ATTiny to Ground

As shown in the photo above

Step 16: Wire the Button Output to Your ATTINY85 (pin 3)

This allows your ATTINY85 to detect when you push your button. Add the wire exactly as shown.

Step 17: Add a 10K Resistor Between the Button and Ground

Add 10 K ohm resistor (Brown, Black, Orange, Gold) between the ground and the button. This is a pull down resistor. When the button is pressed the ATTINY85 reads a HIGH (+3V), when it is not pressed the ATTINY85 reads a LOW (0 V)

Step 18: Add the Buzzer to the Bread Board

Add the buzzer to your bread board. Make sure to add it exactly as shown with the (+) on top.

Step 19: Develop Your CODE

  1. Download the code
  2. 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 20: Adding Dr. Azzy's Board

Add Dr. Azzy's Board Into your Arduino IDE:

  1. Under Files navigate to preferences
  2. preferances>Settings under additional boards managers past in this link: https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json
  3. Under Tools navigate to Boards Manager
  4. Install ATTiny Core by Spence Konde

Step 21: Add Rttl Library to Your Arduino Librarys

To get the buzzer to work add the library here to your Arduino's Library:

https://github.com/cefn/non-blocking-rtttl-arduino

Step 22: Configure the Arduino IDE to Program the ATTiny

Click the tools menu and be make sure the Board, Clock, and Chip are correct

Step 23: Program the ATTiny and Connect Your Bread Board to the AVR Programer

  1. 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.
  2. Take 3 wires and connect pins 2,1,0 on the programmer to the corresponding pins on your bread board. See photos for details.
  3. Take one wire wire and connect pins (-) on the programmer to the corresponding ground on your bread board. See photos for details.
  4. 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 24: 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.

Step 25: Circuit Diagram

A better Circuit Diagram developed by Kyle Neil is shown here and would use a Transistor to control the Buzzer. To be implemented in future versions