Project tutorial

Add Lights and Spooky Music to Your Jack-O-Lantern © CC BY

Have the scariest Jack-O-Lantern on your street by adding glowing lights and spooky music!

  • 579 views
  • 0 comments
  • 2 respects

Components and supplies

Necessary tools and machines

Hy gluegun
Hot glue gun (generic)

Apps and online services

About this project

Video of the build process here

Have the scariest Jack-O-Lantern on your street by adding glowing lights and spooky music! This is also a great way to try out Arduino and programmable electronics because the entire project can be completed without writing code or soldering - although the opportunity is there for those looking to make it their own.

Step 1: Carve the Pumpkin

Hollow out and carve your pumpkin - the spookier the better! Make sure to have openings for eyes and mouth so you are able to see light from LEDS.

Step 2: Assemble the eyes

Cut two pieces off the LED strip that have two pixels each. These will be for the eyes of the pumpkin - you can use more if you like to make them brighter.

Take one of the connectors, and cut the end off. Strip the insulation off each of the three wires. Wrap the exposed wire around the end of a jumper wire, and hot glue (or solder) in place.

Take one of the two pixel strips and slide it under the prongs on the connector, making sure the arrows are pointing away from the jumper wires, and snap connector into place. Add a connector to the other side, and snap into place as well. On the remaining side, attach the other two pixel strip, making sure the arrows are pointing the same way they are with the first.

Step 3: Assemble the candle

Cut an LED strip with four pixels. This will be for the candle in the pumpkin - you can use more if you like to make it brighter.

As before, take one of the connectors, and cut the end off. Strip the insulation off each of the three wires. Wrap the exposed wire around the end of a jumper wire, and hot glue (or solder) in place. Slide the contacts of the LED strip under the prongs on the connector, making sure the arrows are pointing away from the jumper wires, and snap connector into place.

Step 4: Prep the speaker

Take two jumper wires and connect them to the speaker using hot glue. To get this to work, I bent the end of the jumper wire and held it in place until the hot glue had completely solidified.

Step 5: Build the Circuit

Wire Arduino Uno boards to the breadboard. It is important that they both 5v pins are connected to the same rail, and the ground pins for both are also connected to the same rail. This way, both boards will be powered regardless of which board is connected to the power supply.

For each LED strip, connect the positive wire to the positive/5v rail, and the negative wire to the negative/ground rail. Connect the candle LED strip to pin 6, and the LED strip for the eyes to pin 8 on one of the Arduino boards.

Connect one wire from the speaker to the negative/ground rail, and connect the other wire to pin 9 on the other Arduino board.

Note: Two Arduino boards are needed, because the library needed to control the LED strips is not compatible with the code required to play a tone on the Arduino board. You can sort of make it work, but everything gets slowed down, and the sound is choppy.

Step 6: OPTIONAL: Solder Eyes/Candle/LED Instead of Gluing

I made a soldered version using two Arduino Nanos. I cut off the two pins on the end of each board so that I could fit them together on the breadboard. From here, everything is very much the same. I used three strand wire to help keep it a little neater.

The circuit is assembled in a similar fashion, and is perhaps a bit simpler to put together once everything is soldered together.

NOTE: I soldered jumper wires to the ends to make them easy to connect to the breadboard. You can bypass the breadboard altogether and solder all the parts to a prototyping board to make the circuit a little more durable.

Step 7: Program the boards

Open up the Arduino IDE on the desktop, or go to the https://create.arduino.cceditor, and connect the Arduino with the LED strips to your computer. Upload the code linked below. No edits or interaction with the code is necessary unless you want to try changing the speeds, etc. If you did use more than 4 LEDs for either part, you will need to change the numbers in the code to reflect the amount you are using in line 5 for the candle, and in line 8 for the eyes. You can also connect the LED strips to a different pin on the Arduino, by changing the numbers on lines 5 and 12.

code for lights + candle

Next, connect the Arduino with the speaker to your computer, and run the code below - as before, no modifications are necessary. If you are interested in changing the speed (line 14), or the song, you can do so fairly simply here. All you need is to find the list of notes (line 16) and replace them with the notes in the song you want to create. Next change the value of the variable that contains the number of notes to reflect the new length of the song (line 2), and change the frequencies to match the notes you used (lines 2-13).

code for song

Step 8: Troubleshooting

At this point, when the boards are plugged in, you should see the lights from the LEDS, and the hear the tone from the speaker. If something isn't working as expected, here are some good places to start:

  • Check that all the connections are good
  • Make sure both Arduino boards are connected to the same positive and same ground rail
  • Check to make sure each of the components are wired correctly - positive/negative in the right spot, and connected to the pin that the code thinks it is attached at.
  • Make sure all the code was copied into a fresh empty sketch, and nothing was accidentally deleted or added.

Step 9: Put it into the Pumpkin

To power the circuit, you can use a AC - DC converter rated between 7 and 12v, or and cell phone external battery with a usb port.

I used a rubber band to hold the Arduino boards and the breadboard together, and placed them in a plastic bag to keep them from getting pumpkin all over them.

I also wrapped some wax paper around the LEDs for the lights to diffuse them.

I put the whole set up inside the pumpkin, and cut some paper clips in half, and folded them so they could act as staples to hold the LEDs in place.

All that is left to do is plug it in and enjoy!!!

Thank you for reading. If you are interested in seeing future projects, please subscribe to my Youtube channel: More Than The Sum

Enjoy!

Schematics

This is the wiring diagram for the LED strips and speaker
Screen shot 2017 10 22 at 1 xea8kkt3ca

Code

SongArduino
This code is for the song played by the pumpkin
int speakerPin = 9; //change to match pin for speaker
int numTones = 291; //change this to reflect the number of notes in your song
int cs6 = 1109; // frequencies of the notes used in the song
int fs5 = 740;
int d6 = 1175;
int c6 = 1047;
int f5 = 698;
int b5 = 988;
int e5 = 659;
int bf5 = 932;
int ef5 = 622;
int b4 = 494;
int g5 = 784;
int wait = 200;  // length of the notes

int tones[] = { cs6, fs5, fs5, cs6, fs5, fs5, cs6, fs5,  d6, fs5, //notes in the song
	      		  	cs6, fs5, fs5, cs6, fs5, fs5, cs6, fs5,  d6, fs5, 
      			  	cs6, fs5, fs5, cs6, fs5, fs5, cs6, fs5,  d6, fs5,
    		  	  	cs6, fs5, fs5, cs6, fs5, fs5, cs6, fs5,  d6, fs5,
    	  		  	cs6, fs5, fs5, cs6, fs5, fs5, cs6, fs5,  d6, fs5,
      			  	cs6, fs5, fs5, cs6, fs5, fs5, cs6, fs5,  d6, fs5,
    		  	  	 c6,  f5,  f5,  c6,  f5,  f5,  c6,  f5, cs6,  f5,
	      		  	 c6,  f5,  f5,  c6,  f5,  f5,  c6,  f5, cs6,  f5,
      			  	cs6, fs5, fs5, cs6, fs5, fs5, cs6, fs5,  d6, fs5,
	    	  	  	cs6, fs5, fs5, cs6, fs5, fs5, cs6, fs5,  d6, fs5,
	       		  	 c6,  f5,  f5,  c6,  f5,  f5,  c6,  f5, cs6,  f5,
      			  	 c6,  f5,  f5,  c6,  f5,  f5,  c6,  f5, cs6,  f5,
	    	  	  	 b5,  e5,  e5,  b5,  e5,  e5,  b5,  e5,  c6,  e5,
	       		  	 b5,  e5,  e5,  b5,  e5,  e5,  b5,  e5,  c6,  e5,
  	    		  	bf5, ef5, ef5, bf5, ef5, ef5, bf5, ef5,  b5, ef5,
		      	  	bf5, ef5, ef5, bf5, ef5, ef5, bf5, ef5,  b5, ef5,
	      		  	 b5,  e5,  e5,  b5,  e5,  e5,  b5,  e5,  c6,  e5,
  	    		  	 b5,  e5,  e5,  b5,  e5,  e5,  b5,  e5,  c6,  e5,
		      	  	bf5, ef5, ef5, bf5, ef5, ef5, bf5, ef5,  b5, ef5,
	     		    	bf5, ef5, ef5, bf5, ef5, ef5, bf5, ef5,  b5, ef5,
  	    		  	fs5,  b4,  b4, fs5,  b4,  b4, fs5,  b4,  g5,  b4,
	    		    	fs5,  b4,  b4, fs5,  b4,  b4, fs5,  b4,  g5,  b4,
    		  		  fs5,  b4,  b4, fs5,  b4,  b4, fs5,  b4,  g5,  b4,
    	  			  fs5,  b4,  b4, fs5,  b4,  b4, fs5,  b4,  g5,  b4,
      			  	fs5,  b4,  b4, fs5,  b4,  b4, fs5,  b4,  g5,  b4,
	    		    	fs5,  b4,  b4, fs5,  b4,  b4, fs5,  b4,  g5,  b4,
	    	  	  	fs5,  b4,  b4, fs5,  b4,  b4, fs5,  b4,  g5,  b4,
	      		  	fs5,  b4,  b4, fs5,  b4,  b4, fs5,  b4,  g5,  b4,
      		  		fs5,  b4,  b4, fs5,  b4,  b4, fs5,  b4,  g5,  b4};
				
unsigned long current_song_time = 0; unsigned long prev_song_time = 0; int note_count = 0; int on_off = 0; //variables for running the song

void setup(){

}

void loop()
{
	current_song_time = millis();
	if(on_off == 0)
	{
		if (current_song_time - prev_song_time >= 20){
			if(note_count+1==numTones){
				wait = 10000;
				on_off++;
				on_off %= 2;
			} else{
				prev_song_time = current_song_time;
				tone(speakerPin, tones[note_count]);
				on_off++;
				on_off %= 2;
			}
		}
	} else {
		if (current_song_time - prev_song_time >= wait){//delays[note_count]
			prev_song_time = current_song_time;
			noTone(speakerPin);
			note_count++;
			note_count %= numTones;
			on_off++;
			on_off %= 2;
			wait = 200;
		}
	}
}
Eyes + CandleArduino
This is the sketch to control the LEDs used in the eyes of pumpkin as well as the candle.
#include <Adafruit_NeoPixel.h>

//initialize the candle, and variables related to the candle
//modified from: https://codebender.cc/sketch:67754#Neo%20Candle.ino
#define lPIN 6    //this is the pin the candle LEDs are connected to
int numpix = 4;  //set the number of Pixels you have/want in the candle - more = brighter
int randNumber; int color; int wait;  int randpix; boolean x = true; unsigned long prevCandleTime;  //additional variables used to operate candle
Adafruit_NeoPixel cstrip = Adafruit_NeoPixel(numpix, lPIN, NEO_GRB + NEO_KHZ800);  //define the candle led strip

//initialize the eyes, and variables used to control eyes
// modified from: http://www.tweaking4all.com/hardware/arduino/adruino-led-strip-effects/#fadeinout_rgb
#define fadePin 8   //this is the pin the glowing eye LEDs are connected to
#define NUM_LEDS 4  //set the number of Pixels you have/want in the eyes - more = brighter
int fadeWait = 3;  // sets speed of eye fade.  smaller = faster, bigger = slower
unsigned long currentFadeTime = 0; int j = 0; int k = 0; boolean fadeIn = true;
Adafruit_NeoPixel fadeStrip = Adafruit_NeoPixel(NUM_LEDS, fadePin, NEO_GRB + NEO_KHZ800); //define the led strip for the eyes

void setup() {
	pinMode(2, INPUT);  //use pin 2 as input for the random seed - pick an unused analog read pin
	randomSeed(analogRead(2));  //Set random number generator seed from analog pin 2
	
	cstrip.begin();
	cstrip.show(); // Initialize all candle pixels to 'off'
  
  fadeStrip.begin();
  fadeStrip.show(); // Initialize all eye pixels to 'off'
}

void loop(){
	candle();
  RGBLoop();
}  //end main loop

void candle(){
  if(x){
    wait = random(80, 120);  //set a random wait period
	  randpix = random(0, numpix + 1); //choose a random number of pixels
	  color = random(0, 2); //Pick either yellow or orange
	  for (int i = 0; i < numpix / 2; i++){ //so it leaves a certain number of yellow pixels on (number of pixels/3)
		  cstrip.setPixelColor(i, 255, 120, 0);  //set the number of pixels to turn on and color value (yellowish)
	  }
	  cstrip.show(); //turn pixels on
  }
  
	if (color == 0){   //if red was chosen
		flickred(cstrip.Color(115, 50, 0), wait, randpix); // call flickred and pass it the red (orangeish) color values - change values to change color
	} else {  // otherwise use yellow
		flickYellow(cstrip.Color(180, 80, 0), wait, randpix); // call flickYellow and pass it the yellow color values (change values to change color), and wait time and random pixel count
	}
}

// Function for when red is chosen
void flickred(uint32_t c, uint8_t wait, uint8_t p) {
	if(x){
	  for (int i = 0; i < p - 2; i++){ //loop for given random pixel count (passed from loop)
		  cstrip.setPixelColor(i, c);
	  }
	  cstrip.show();  //turn pixels on
    x = false;
	}else{
	  if(millis()-prevCandleTime>wait){
	    prevCandleTime = millis();
    	for (int i = 0; i < p; i++) {
		    cstrip.setPixelColor(i, 0);        //turn pixel off
    	}	  
    	x = true;
	  }  
	}
}  //end flickred

// function for when yellow is chosen
void flickYellow(uint32_t c, uint8_t wait, uint8_t p) {
	if(x){
	  for (int i = 0; i < p ; i++){ //loop for given random pixel count (passed from loop)
		  cstrip.setPixelColor(i, c);
	  }
	  cstrip.show();  //turn pixels on
    x = false;
	}else{
	  if(millis()-prevCandleTime>wait){
	    prevCandleTime = millis();
    	for (int i = 0; i < p; i++) {
		    cstrip.setPixelColor(i, 0);        //turn pixel off
	    }
	    x = true;
	  }
	}
}  //end flickYellow

void RGBLoop(){
  if(millis()-currentFadeTime>fadeWait){
    currentFadeTime = millis();
    if(fadeIn){
      switch(j) { 
        case 0: setAll(k,0,0); break;
        case 1: setAll(0,k,0); break;
        case 2: setAll(0,0,k); break;
      }
      fadeStrip.show();
      if(k==255){
        fadeIn=false;
      } else {
        k++;
      }
    } else {  // Fade OUT
      
      switch(j) { 
        case 0: setAll(k,0,0); break;
        case 1: setAll(0,k,0); break;
        case 2: setAll(0,0,k); break;
      }
      fadeStrip.show();
      if(k==0){
        fadeIn = true;
        j++;
        j%=3;
      } else {
        k--;
      }
    }
  }
}

void setAll(byte red, byte green, byte blue) {
  for(int i = 0; i < NUM_LEDS; i++ ) {
    fadeStrip.setPixelColor(i, fadeStrip.Color(red, green, blue));
  }
  fadeStrip.show();
}

Comments

Similar projects you might like

Version 2.0 Advanced Attendance System (Without Ethernet)

Project tutorial by GadgetProgrammers

  • 2,545 views
  • 5 comments
  • 43 respects

Get The Arduino Dice

by Ingo Lohs

  • 249 views
  • 0 comments
  • 4 respects

Control LED Using Your Voice Command

by IoTBoys

  • 607 views
  • 0 comments
  • 7 respects

Critter: Crawling Arduino Robot

Project showcase by Slant Concepts

  • 4,837 views
  • 10 comments
  • 30 respects

Musical Fairy Lights

Project tutorial by Ian Cumming

  • 483 views
  • 0 comments
  • 4 respects

Cloud Costume

Project tutorial by Monica Houston

  • 1,029 views
  • 3 comments
  • 10 respects
Add projectSign up / Login