Project tutorial
Sensitive Jack-o'-Lantern

Sensitive Jack-o'-Lantern © GPL3+

A jack-o'-lantern which change color when someone passes in front of it.

  • 46 views
  • 0 comments
  • 5 respects

Components and supplies

Apps and online services

About this project

Halloween is near so I have wanted to use my new Elegoo Super starter Kit to do a Sensitive Jack-o'-Lantern.

I'm thinking about a lantern which change its color when someone passes in front of it, but I want also to control the light and the sensor.

Now we see how to do that.

HARDWARE:

In this case the circuit is quite easy, there are an ultrasonic sensor, an IR Receiver Module, some LEDs and transistors.

For the first time, thanks to Elegoo, I can use an IR Remote Control, so with this I can control the lantern.

This is the circuit diagram:

STRUCTURE:

I haven't wanted to use a real pumpkin but I have wanted to build it by myself.

I need two things:

  • A photo of a jack-o'-lantern
  • A sheet

In this way I can print the photo on the sheet and with a pedestal I can substain the jack-o'-lantern and all circuits.

I created this structure with some cardboard which will sustain the lantern, in this way I can also hide the ultrasonic sensor.

All circuits stand in this structure.

You can do it with other materials such wood or plastic.

I put the circuits on the bottom and all LEDs on the vertical layer, in this way the jack-o'-lantern's photo covers the LEDs but the final effect is a light inside the our "pumpkin."

Finally, this is my project I know it can have some defects but for me the idea is good and it is easy and rapid to do.

Code

Sensitive Jack-o'-lanternArduino
//Sensitive Jack-o'-lantern with ELEGOO

#include <IRremote.h>

//Ultrasonic sensor
int eco = 8;
int trigger = 7;
//IR Receiver Module
int receiver = 9;
//variables
int led_color = 0;
int command = 0;

IRrecv irrecv(receiver);     // create instance of 'irrecv'
decode_results results;      // create instance of 'decode_results'


//This function returns a number from 0 to 11 according which command IR Module receives
int translateIR() // takes action based on IR code received
{

  switch (results.value)

  {                                           //Button
    case 0xFFA25D:  return 10;   break;       //POWER
    case 0xFFE21D:  return 11;   break;       //FUNC/STOP
    case 0xFF6897:  return 0;    break;       //0
    case 0xFF30CF:  return 1;    break;       //1
    case 0xFF18E7:  return 2;    break;       //2
    case 0xFF7A85:  return 3;    break;       //3
    case 0xFF10EF:  return 4;    break;       //4
    case 0xFF38C7:  return 5;    break;       //5
    case 0xFF5AA5:  return 6;    break;       //6
    case 0xFF42BD:  return 7;    break;       //7
    case 0xFF4AB5:  return 8;    break;       //8
    case 0xFF52AD:  return 9;    break;       //9
    case 0xFFFFFFFF: return command;   break;      //REPEAT

    default:
      return command;             //OTHER

  }
  delay(500); // Do not get immediate repeat

} //END translateIR


//This function takes an action based on variable c which determines which LEDs turn on
void color(int c) {
  switch (c) {
    case 0:
      digitalWrite(13, LOW);
      digitalWrite(12, LOW);
      digitalWrite(11, LOW);
      break;
    case 1:
      digitalWrite(13, HIGH);
      digitalWrite(12, LOW);
      digitalWrite(11, LOW);
      break;
    case 2:
      digitalWrite(13, LOW);
      digitalWrite(12, HIGH);
      digitalWrite(11, LOW);
      break;
    case 3:
      digitalWrite(13, HIGH);
      digitalWrite(12, HIGH);
      digitalWrite(11, LOW);
      break;
    case 4:
      digitalWrite(13, LOW);
      digitalWrite(12, LOW);
      digitalWrite(11, HIGH);
      break;
    case 5:
      digitalWrite(13, HIGH);
      digitalWrite(12, LOW);
      digitalWrite(11, HIGH);
      break;
    case 6:
      digitalWrite(13, LOW);
      digitalWrite(12, HIGH);
      digitalWrite(11, HIGH);
      break;
    case 7:
      digitalWrite(13, HIGH);
      digitalWrite(12, HIGH);
      digitalWrite(11, HIGH);
      break;
  }
}
//End color

void setup() {
  //IR
  pinMode(receiver, OUTPUT);  //Pin 9
  

  //Ultrasound sensor
  pinMode(eco, INPUT);  //Pin 8
  pinMode(trigger, OUTPUT); //Pin 7

  //Pin's LED
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);

  irrecv.enableIRIn(); // Start the receiver

}

void loop() {
  
  if (irrecv.decode(&results)) // have we received an IR signal?
  {
    command = translateIR();
    if(command<=7) color(command);
    Serial.println(command);
    irrecv.resume(); // receive the next value
  }

  while (command == 11) {             // numeber 11 activates the ultrasound sensor
    digitalWrite( trigger, LOW);

    digitalWrite( trigger, HIGH);

    delayMicroseconds( 10 );

    digitalWrite( trigger, LOW );

    long tm = pulseIn( eco, HIGH);

    long r = 0.0343 * tm / 2;         //cm
    
    delay(20);
    
    if (r <= 40) {  //if r<40cm this means that someone passes in front of it
      led_color = random(0, 8); //In this way it can light the LEDs casually
      color(led_color);
      delay(500);
    }

    if (irrecv.decode(&results)) // have we received an IR signal?
    {
      command = translateIR();
      Serial.println(command);
      irrecv.resume(); // receive the next value

    }
  }


}

Custom parts and enclosures

schematic
circuit_diagram_CDbQvOjgkQ.sch

Comments

Similar projects you might like

Remote Controlled Jack-o-Lantern

Project tutorial by Josh From BreakoutBros.com

  • 1,592 views
  • 0 comments
  • 1 respect

Add Lights and Spooky Music to Your Jack-O-Lantern

Project tutorial by aams86

  • 5,098 views
  • 0 comments
  • 19 respects

Light Sensitive Theremin

Project tutorial by 3 developers

  • 1,742 views
  • 0 comments
  • 3 respects

Newbie Music Player

Project in progress by Michael Marinis

  • 3,746 views
  • 2 comments
  • 12 respects

Create a People Counter Controlled by an Android App

Project tutorial by Kutluhan Aktar

  • 3,064 views
  • 2 comments
  • 7 respects
Add projectSign up / Login