Motion Sensor Candle Delighter

by dkirk41 in Circuits > Microcontrollers

124 Views, 0 Favorites, 0 Comments

Motion Sensor Candle Delighter

IMG_9709.JPG
IMG_9660.JPG

Never forget to blow out your candle with this project. Create an automatic candle delighter based on the motion in the room. When no motion has been detected a lid will cover the candle - putting it out.

Supplies

Electronics:

Non technical materials:

  • Candle
  • Cardboard
  • Aluminum Foil
  • Popsicle stick

Set Up PIR Sensor

Screenshot 2023-01-25 2.04.17 PM.png
Screenshot 2023-01-25 2.08.12 PM.png
IMG_9621.JPG

A PIR sensor detects when motion is in an area (the boundary range can be chosen by you). **I used the Elegoo pdf (pg 123) to learn about this sensor.

Wiring: Begin by setting up your PIR sensor. (Hold your PIR sensor in the orientation as depicted above) The leftmost pin should be plugged into power (5v). The middle pin will be plugged into a digital pin (if you are using my code: use digital pin 2) The rightmost pin will be plugged into ground.

Sensitivity Adjustment: Turn the dial on the right (sensitivity adjust) completely counter-clockwise (to the left) so that the range will be 7 meters.

Time Delay: Turn the dial on the left (time delay adjust) completely counter-clockwise (to the left) so that the time delay will be 3 seconds. This means when the sensor detects motion it will be set to high for 3 seconds, if no motion is detected during that time it will delay for an additional 3 seconds until turning off. (You can increase the time delay depending on how soon after there is no motion that you would like for your candle to turn off - do this by turning the dial clockwise (to the right) ) For testing purposes I had it turned to the shortest delay; however, when in use I turned it completely to the right so that there would be a 10 minute time delay.

Trigger Mode: The control in the top right corner for the trigger mode. Follow the position of the jumper in the second picture to put your jumper into a repeatable trigger mode. This means that the time delay will be reactivated every time motion is detected.

Set Up Servo

IMG_9623.JPG
IMG_0114.JPG

A servo has three wires:

  • Plug the black/brown wire into ground
  • Plug the red wire into 5v
  • Plug the yellow/orange wire into a digital pin (for my code: use digital pin 6)


Review the second photo to make sure all of your wires are plugged in correctly.

Upload Code

Copy and paste my code from below: (reminder to change the digital pins if you did not use the same pins as me)


int onBoard = 7; //will light up onboard led when the pir sensor detects motion

int inputPin = 2;
int val = 0;
   
Servo myServo;

void setup() {
  pinMode(onBoard, OUTPUT);
   
  pinMode(inputPin, INPUT);
   
  myServo.attach(6);
  myServo.write(10);
}

void loop() {
  val = digitalRead(inputPin);
   
  if(val == HIGH)
  {
    digitalWrite(onBoard, HIGH);
    myServo.write(160);
  }

  else
  {
    digitalWrite(onBoard, LOW);
    myServo.write(80);
  }
}

Create Lid & Tower

IMG_9625.JPG
IMG_9624.JPG

Create the lid:

  1. Trace and cut a circle slightly larger than the opening of the candle onto cardboard.
  2. Cover cardboard with multiple layers of aluminum foil (I used 3).
  3. Attach a Popsicle stick to the center of the lid (this will be used to connect to your servo fin).
  4. Glue Popsicle stick onto servo fin

Create the tower:

  1. Create a 4 sided tower out of cardboard tall enough that when the servo rests on top it will cover the candle.
  2. If needed create a lip so that the servo can rest flat on top of the tower.

*I used hot glue to put this together

Set Up Candle Delighter

IMG_9709.JPG
January 31, 2023

Attach servo fin to servo and glue or tape servo onto your tower. Place tower next to candle at a far enough distance that when the servo is activated the lid will completely cover the candle. Place PIR sensor where it can detect the most motion (mine is attached to the wall with masking tape near my desk as this is where I want my candle to be). Connect argon to power source and flash your code.


The video depicts the invention working with a 10 minute time period of no motion in between.