GadhaGod
Published

Arduino Centipede Dropping Prank

Scare infiltrators of your room!

BeginnerFull instructions provided2,104
Arduino Centipede Dropping Prank

Things used in this project

Hardware components

SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Arduino Nano Every
Arduino Nano Every
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1

Hand tools and fabrication machines

glue
Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Centipede Dropper

Code

Centipede Dropper

C/C++
#include <Servo.h>
int trigPin = 5;    // Trigger
int echoPin = 3;    // Echo
Servo myservo;
long duration;
 
void setup() {
  //Serial Port begin
  Serial.begin (9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  myservo.attach(20);
  myservo.write(180);
}
 
void loop() {
  digitalWrite(trigPin, LOW);
  delayMicroseconds(5);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
 
  duration = pulseIn(echoPin, HIGH);
  Serial.println(duration);

  if ((duration <= 2000) and (duration != 0)){
    myservo.write(0);
    delay(1000);
    myservo.write(180);
    delay(5000);
  }
  

  

}

Credits

GadhaGod
17 projects • 21 followers

Comments