Scary Halloween Pumpkin

Introduction: Scary Halloween Pumpkin

Once Halloween arrives it’s time to get creative in decorating our surroundings. This project involves creating a Halloween pumpkin that emits light and sound when the proximity detector is activated. This is a project where you will learn how to use the Arduino and its add-ons once you have created the corresponding code.

Step 1: Step 1: Create De Phisical Pumpkin

To make our own pumpkin design we took various types of inspiration about the shape of the face through pinterest.com.

The first step to personalize our pumpkin was to give it a layer of black puncture, once the paint layer was completely dry and the final design was chosen, we made the corresponding cuts with the appropriate size for the RGB LEDs (eyes) and the motion sensor ( mouth). Once the areas adapted to include both electronic components are given a second coat of paint.

Let it dry for 12 hours and the design is ready to use!

Step 2: Step 2: Assemble the Arduino System

Once the pumpkin is created, it is time to assemble all the accessories with the motherboard.

1. First we start programming the two RGB LEDs in order to get the affection we want. In this example they will be red and purple.

2. Along with the LEDs, the distance sensor must be programmed so that once it detects any movement at 40 cm, it causes the red lights to flash purple and red.

3. An MP3 sound must be downloaded and saved to the microSD card. Be sure to save them to your microSD card using track names like Track001.mp3. This mini SD will then be located in the DfPlayer accessory.

ELECTRONICS MATERIALS:

  • Breadboard
  • Controller Board
  • 2 RGB LED
  • 5 Resistances
  • Breadboard Jumper
  • Ultrasonic Sensor
  • 9 V Battery
  • DFPlayer mini (MICRO SD)
  • Speaker

Step 3: Step 3: the Code

To make all the accessories work, we need to create a code for the Arduino Uno.

CODE SCARY HALLOWEEN PUMPKIN:

#include "Arduino.h"
#include "SoftwareSerial.h"

#include "DFRobotDFPlayerMini.h"

SoftwareSerial mySoftwareSerial(9, 13); // RX, TX)

DFRobotDFPlayerMini myDFPlayer;

const int trig = 7;

const int echo = 8;

//variables dels PINS de l'ultrasonic sensor

long duration;

int distance;

void setup() {

pinMode(trig, OUTPUT);

pinMode(echo, INPUT);

mySoftwareSerial.begin(9600);

if (!myDFPlayer.begin(mySoftwareSerial)) { // Use

softwareSerial to communicate with mp3.

Serial.println(F("Unable to begin:"));

Serial.println(F("1.Please recheck the connection!"));

Serial.println(F("2.Please insert the SD card!"));

while (true) {

delay(0); // Code to compatible with ESP8266 watch dog.

}

}

myDFPlayer.volume(30);

Serial.begin(9600);

// initialize digital pin LED_BUILTIN as an output.

pinMode(6, OUTPUT); // red

pinMode(3, OUTPUT); // green

pinMode(5, OUTPUT); // blue

pinMode(12, OUTPUT); //red

pinMode(10, OUTPUT); // green

pinMode(11, OUTPUT); // blue

}

void loop() {

//clears the trig Pin

digitalWrite(trig, LOW);

delayMicroseconds(2);

//Sets the trig pin on high state for 10 microseconds

digitalWrite(trig, HIGH);

delayMicroseconds(10);

digitalWrite(trig, LOW);

//Reads the echo pin, returns the sound wave travel time in microseconds

duration = pulseIn(echo, HIGH);

//Calculating the distance en cm distance = duration * 0.034 / 2;

int i=1;

if (distance <= 30) {

if (i<=5) {

i++;

myDFPlayer.play(i);

delay(200);

}

if (i > 5) {

i = 1;

}

analogWrite (6, 255);

analogWrite (3, 0);

analogWrite (5, 0);

delay(80);

analogWrite (12, 255 );

analogWrite (10, 0);

analogWrite (11, 0);

delay(80);

analogWrite (6, 0);

analogWrite (3, 0);

analogWrite (5, 255);

delay(80);

analogWrite (12, 0);

analogWrite (10, 0);

analogWrite (11 , 255);

delay(80);

}

else {

pinMode(6, OUTPUT); //red

pinMode(3, OUTPUT); //green

pinMode(5, OUTPUT); //blue

pinMode(12, OUTPUT); //red

pinMode(10, OUTPUT); //green

pinMode(11, OUTPUT); //blue

}

}


Step 4: Step 4: Enjoy!

Now the halloween pumpkin is ready, you just have to put it in some corner of the house or garden for when detects someone get a good scare!

_____________

This Scary Halloween Pumpkin project is created through a coding of the Arduino program together with its implementation in a physical Arduino Uno. The objective of the project is that through the movement sensor incorporated in the mouth of the pumpkin it is activated when it detects movement. Therefore, the RGB LEDs will change color during this process in which it detects movement in addition to playing the .mp4 files inserted.

Be the First to Share

    Recommendations

    • Anything Goes Contest

      Anything Goes Contest

    Comments