Kristian Blåsol
Published © GPL3+

Dropping Spider on Doorbell - Halloween Scare Prank

A quick halloween scare prank using an Arduino, HC-SR04 ping sensor, and a servo. A spider drops on anyone trying to ring the bell.

BeginnerFull instructions provided1 hour3,407
Dropping Spider on Doorbell - Halloween Scare Prank

Things used in this project

Hardware components

Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
Any cheap HC-SR04 from ebay or similar will work.
×1
RobotGeek Continuous Rotation Servo
RobotGeek Continuous Rotation Servo
Any servo will work.
×1
Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
Any model of Arduino will work. Doesnt have to be UNO.
×1

Story

Read more

Schematics

Schematics for ep.31 Spider dropping on doorbell.

A simple schematics on how to connect the HC-SR04 and Servo to the Arduino.

Code

The code for the dropping spider halloween prank

Arduino
Code from Anything Arduino episode 31. Dropping spider on doorbell Halloween scare prank.
#include <Servo.h>

//Ping sensor
const int pingPin = 7;
long pingSendTime = 0;

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position



void setup()
{
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object

}

void loop()
{
//Ping sensor code:
  if (millis()>pingSendTime+100) {
    long duration;
    pingSendTime=millis();
    pinMode(pingPin, OUTPUT);
    digitalWrite(pingPin, LOW);
    delayMicroseconds(2);
    digitalWrite(pingPin, HIGH);
    delayMicroseconds(5);
    digitalWrite(pingPin, LOW);
  
    // The same pin is used to read the signal from the PING))): a HIGH
    // pulse whose duration is the time (in microseconds) from the sending
    // of the ping to the reception of its echo off of an object.
    pinMode(pingPin, INPUT);
    duration = pulseIn(pingPin, HIGH);
    if (duration<380 and duration>100) {
        for (pos = 0; pos <= 60; pos += 1) { // goes from 0 degrees to 180 degrees
          // in steps of 1 degree
          myservo.write(pos);              // tell servo to go to position in variable 'pos'
          delay(1);                       // waits 15ms for the servo to reach the position
        }
      delay(2500);
      for (pos = 60; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
        myservo.write(pos);              // tell servo to go to position in variable 'pos'
        delay(15);                       // waits 15ms for the servo to reach the position
      }
    }
  }  
//End ping sensor code.
 
} //void loop

Credits

Kristian Blåsol

Kristian Blåsol

5 projects • 27 followers
Maker, Dad, Geek, Musician, System Engineer, Android Tinkerer... (Not in that specific order)

Comments