Sunday, August 12, 2018

"Spooky Old Tree" - The Mouse and The Spider

Despite their vastly different appearances, the Mouse and the Spider are basically the same prop.  They use exactly the same electronic components and the difference in their code is a single digit, so I'm going to cover them together.


Build (Mouse)

The mouse is my favorite of the three props.  The image was taken directly from the book and he has nice bounce when he comes up. His eyes and mouth are coated with glow-in-the-dark paint, so when you activate him with a ultraviolet flashlight, he has a neat look.

We started with a small tagboard box that originally held trash bags.  We painted the interior black and covered it with wood-grain contact paper.  The light sensor is in the middle of the knothole, but to make a more obvious aiming point, we glued on a plastic spider.

To make the mouse, I took a picture of the book page where he appears and loaded it up into a pico-projector.  We pointed that straight down and adjusted the height so that he was blown up to the proper size and my wife traced over him.  After coloring, we mounted him on a light piece of cardboard.

Originally, I thought I would mount him using an L-shaped bracket made from a couple of craft sticks, but we first needed to determine the exact angle and length.  So, for testing purposes I just hooked a piece of wire to a servo horn, figuring we could bend and adjust it until we got the right size and then build the final mount based on that.  However, when we started testing we both loved the way he popped up and wiggled from the wire's flexing, so we just ended up using that.  He's just stuck on with some pieces of Blue-Tack.

Here's a view from the rear.

As you can see, it's a bit of a hot mess.  These are temporary props designed for light duty cycles, so we didn't try to clean things up too much.  The servo is mounted on a block of wood glued to the side and bottom of the box.  I added some wire wrapped around the servo to make sure it didn't move, since the clearance to get the mouse up and out of the hole is a bit tight.  The servo horn is attached so that the zero position is actually pointed down toward the bottom of the box.  When activated, it jumps up to 60 degrees, taking the mouse with it.  Like the Owl, the controller is an Arduino Nano powered by a cellphone USB power bank. 

Build (Spider)

The Spider is the most complicated physical build since it has several different graphic elements.  We wanted something that would fit neatly into the hallway opening, but we didn't have a big enough piece of cardboard span the distance, so we also cut our a pair of cardboard "wings" and attached one to each side vertically  with hot glue to make a nice arch that filled the space.  It's hung using a pair of grommets that slip over some finishing nails I put on the back of the hallway support beam.  It can be hung or removed in a matter of seconds.  Like the Mouse, the cardboard is covered in wood-grain contact paper.

The spiderweb is black yarn that my wife wove through holes she punched in the cardboard and then glued down.  The light sensor is in the middle of the web and a plastic spider with a jeweled back was glued on to give a bit more visual interest. 

To help fill up the space, my wife drew and cut out three bats.  Their eyes are coated with luminous paint to give an eerie look under ultraviolet light.

Here's the rear view.
The controller (another Nano) and its power bank are mounted with Blue-Tack on a shelf made from a piece of molding hot-glued to the cardboard.  A smaller shelf holds the servo, which is wired in place.

The servo horn has been extended with a five-inch piece of craft stick and positioned so that zero is straight up.  When activated, the servo rotates 90 degrees (to the right in this picture) and ends up pointing at the large white circle.  The Spider is attached to a piece of black yarn fastened to the stick that goes over a push pin behind the white circle (six inches out from the servo center), and drops down a couple of inches below the cardboard arch.

Circuitry

Here's the schematic for both the Mouse and the Spider.
As before, it consists of an Input side and an Output side.

The input uses exactly the same components as described for the Owl; an LDR and a resistor that form a voltage divider.  Refer to the post about building the Owl if you want a more detailed explanation of how it works.

The output side is even simpler.  It's just a single servo tied to power and ground, with its control wire attached to an output pin of the Nano.  There's really not much else to say about it.

Here's the breadboard diagram in case you want to mock it up.

Code

The code for the Mouse and the Spider is even simpler than that for the Owl.  The only real changes are the simplification caused by the prop only being able to do one thing, and the code required to run the servo.  This program also includes the Calibrate() routine to make sure the system has an appropriate triggerpoint at all times.  See the Owl post for more details. 

#include<Servo.h>
Servo myServo;
float triggerpoint;
long unsigned caltime;

void Calibrate(){
  triggerpoint=analogRead(A1)+60;
  caltime=millis()+10000;
}

void setup(){
  myServo.attach(9);
  myServo.write(0);
  Calibrate();
}

void loop(){
  if(analogRead(A1)>triggerpoint){
    myServo.write(60); //use 90 for the Spider
    delay(1000);
    myServo.write(0);
  }
  if(millis()>caltime){
    Calibrate();
  }
}

The grandkids love these props and they were a lot of fun to make.  If you build something like them, please let me know.

3 comments:

JMR777 said...

Hats off to you, Mike, building the hardware and software to make this neat tree. Wish I had talent like yours.

Mike said...

Thanks. Glad you liked it. I really enjoy working on these projects and I appreciate that you took time to take a look and leave a comment.

Best Shallow Mount Subwoofer! said...
This comment has been removed by a blog administrator.