Introduction: Nightmare Room

About: Just an ordinary person who loves #thinking and #tinkering

Halloween is coming. Just realized that I have so many horror books. Yes, I love R.L. Stine so much. Being left by my wife and kids at weekend, I dream of these Nightmare Room series keep falling from the shelf. Are these books really haunted? Or is it the room?

Well, it is time to start a new project. I enjoy making the video using this simple Arduino setup.

Step 1: Materials

Don't forget to order take away Chinese noodles before you start this project. Well, we need about 4" of a chopstick ^_^

Step 2: Wiring Ultrasonic Sensor

Refer to image and jumper wires' colors.


Step 3: Servos

This is how I setup the servos. I call it the lower servo and the upper servo.

  • Follow the position of image #1 to #6.
  • Pick appropriate servos' horns.
  • You can stick the lower servo's horn to upper servo's body by using adhesive tape or hot glue.
  • Picture #1, #2 and #3 are about positioning the lower servo.
  • Picture #4, #5 and #6 are about positioning the upper servo.
  • Use binder clips or hot glue to clip the chopstick on upper servo's horn as in picture #7 and #8 below.

Step 4: Wiring the Servos

Refer to image and jumper wires' colors. Read these table per row.

Lower ServoUpper ServoArduinoPower +Power -Color
Brown(Gnd)Breadboard -Grey
Red(Vcc)Breadboard +Blue
Brown(Gnd)Breadboard -Purple
Red(Vcc)Breadboard +Green
VinBreadboard +Red
GndBreadboard -Black

Last thing to do is connect Breadboard + to Battery + and connect Breadboard - to Battery -

Step 5: Servos Stand

Mark the lower servo's base on a piece of plywood and cut a hole for the servo to sit in. Before doing this, measure where you want the servos sit on your shelf. You can simply stick the servos to the shelf with hot glue without using plywood. This project is temporary and hot glue is easily removed.

Step 6: Code

Upload this sketch to your Arduino :

 * Chienline @2017
 * Halloween Book Dropper
 * When an object is detected at certain distance, Servos drop a book.
#include <Servo.h>
Servo lServo5;   // Lower Servo
Servo uServo6;  // Upper Servo

//defines pins numbers
const int trigPin = 9;
const int echoPin = 10;
const int ultraVccPin = 11;
const int ultraGndPin = 12;

// defines variables
long duration;
int distance;
int readyForAction;

void setup() {
  pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
  pinMode(echoPin, INPUT); // Sets the echoPin as an Input
  pinMode(ultraVccPin, OUTPUT);
  pinMode(ultraGndPin, OUTPUT);
  digitalWrite(ultraVccPin, HIGH); // Sets 5V pin to power HC-SR04
  digitalWrite(ultraGndPin, LOW); // Sets GND pin to power HC-SR04
  int readyForAction = 1;
  //Serial.begin(9600); // Starts the serial communication

void loop() {
  // Clears the trigPin
  digitalWrite(trigPin, LOW);

  // Sets the trigPin on HIGH state for 10 micro seconds
  digitalWrite(trigPin, HIGH);
  digitalWrite(trigPin, LOW);

  // Reads the echoPin, returns the sound wave travel time in microseconds
  duration = pulseIn(echoPin, HIGH);

  // Calculating the distance into centimeter
  distance= duration*0.034/2;

  //if distance <= 300 cm then drop the book;
  if (distance <= 300){
    //Serial.println("Object Detected!");
    delay(400); //delay 0.4 second before get back to standbyPosition;
    delay(300000); //delay 5 minutes before next ultrasonic detecting;
    readyForAction = 1;

  // Prints the distance on the Serial Monitor
  //Serial.print("Distance: ");

void dropTheBook(){
  readyForAction = 0;

void standbyPosition(){

Step 7: Set Up the Shelf

  • Give room to your gadget by moving the books forward, next to the edge of the shelf. This is crucial not only giving room to your gadget but also to make sure the book fall down and not only moved out from the line.
  • Place your gadget behind the book. Make sure the base sit well. Put something heavy on the plywood. Then test the servos's horns on their pushing position.
  • Put your books back on the shelf and pick one to be dropped. Of course you need to pick a light one ;)

Why we need two servos when we can do it with only one? Well, yes you are right. The upper servo with chopstick can do the drop. My idea using the lower servo is to hide the upper servo. When the book is dropped at the first time, the target will pick it up and put it back on the shelf without any suspicios. The upper servo will be hidden to the side and will not be seen. After 5 minutes delay, the ultrasonic sensor will start working again. This second drop will do the trick. It is terrifying. Target has put the book back and make sure it sits well on the shelf, then how can it fall again?

Step 8: Finishing

Line up the books back on the shelf. Make sure the target book is loose. Insurance for the book to fall.

It is terrifying when the target pick up and read the book's cover. The Nightmare Room ...
Halloween Contest 2017

Participated in the
Halloween Contest 2017