ParzivalUK
Published

Scary Spider Droppper with motion sensor

Drops a spider when people come within 30cm of your door @ halloween, then winds itself back up

BeginnerShowcase (no instructions)591
Scary Spider Droppper with motion sensor

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
DS04-NFC 360 degree continuously rotating DC servo
×1
Breadboard (generic)
Breadboard (generic)
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
180 Degree Servo Motor HS-311
×1

Story

Read more

Schematics

Wire Layout

Code

Spider Dropper Arduino Uno code

Arduino
Very simple code for programming your arduino uno for this project
#include <Servo.h>
#include <NewPing.h>

#define TRIGGER_PIN   7  // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN      7  // Arduino pin tied to echo pin on the ultrasonice sensor.
#define MAX_DISTANCE  200 // Maximum distance we want to ping fro (in centimeters). Maximum sensor distance is rated at 400-500cm.

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maxium distance.

Servo drop; //180 degree servo
Servo lift; //continuous rotation servo
int state = 0; // state of 0 means don't drop the spider again until no one is in front of the ping senser - e.g. a "debounce"

int storeCM = 0;

//Important Variables to Addjust!
int tripdistance = 40; //drop spider when object is within 40 CM of Ping Sensor!
int lifttime = 16000; // 100 = 1 Second. Depending on how long you string is and/or how high up your want the spider, adjust this time to lift the spider back up!


void setup() {
  Serial.begin(115200);
  drop.attach(9); // attach the "Drop" servo (the 180 degree servo) on Digital Pin 9
  lift.attach(10); // attach the "Lift" servo (the continuous rotation servo) on Digital Pin 10
  drop.write(150); // drop to make sure the spider is down
  delay(1000);
  drop.write(80);
  lift.write(180); // lift the spider up on startup
  delay(lifttime);
  lift.write(90);  

}

void loop() {
  Serial.print("Distance: ");
  Serial.println(sonar.ping_cm()); // Send ping, get distance in cm and print result ( 0 = outside set distance range)
  storeCM=sonar.ping_cm();

  if(storeCM <= tripdistance && storeCM > 3 && state == 1) {
    Serial.println("DROP THE SPIDER!");
    drop.write(150); //Drop the Spider!
    delay(5000); // wait 5 seconds until we lift the spider up by winding string
    drop.write(80); // position to lift the spider up by winding string
    lift.write(180);
    delay(lifttime); //lifting the spider
    lift.write(90); // stop lifting the spider
    delay(1000);
    delay(100);
    state = 0;    
  }

  if(storeCM > tripdistance && state == 0) {
    state = 1;
  }

}

Credits

ParzivalUK
0 projects • 0 followers
Contact

Comments

Please log in or sign up to comment.