Introduction: Dancing Tippy With an Arduino and Stepper Motor

The Tippy was created completely by accident.

To say anymore about it would require me to just make some stuff up.

Heres a video for you entertainment:

Important Notes:

This project assumes you have a basic knowledge of Arduino and soldering.

The first 3 steps of this Instructable are literally copied from the "Secret Knock Detecting Door Lock," Instructable by Grathio.

https://www.instructables.com/id/Secret-Knock-Detec...

Step 1: Step 1: Tools, Supplies, and Skills

Skills:

To complete this project you should be able to do the following:

Basic soldering

Read a basic schematic

Basic knowledge of microcontrollers (I'll be using the Arduino.)

Tools:
Drill and an assortment of drill bits

Soldering iron and solder

Pliers

Screw drivers

Heat-shrink tubing and/or electrical tape

Wire stripper

Safety glasses

Gloves

Materials:

(1) Adafruit Pro Trinket - 5V 16MHz - https://www.adafruit.com/products/2000

(1) Small Reduction Stepper Motor - 5VDC 32-Step 1/16 Gearing - https://www.adafruit.com/products/858

(1) Stepper Motor Driver Breakout board - https://www.adafruit.com/products/2448

(1) Piezo Buzzer - PS1240 - https://www.adafruit.com/products/160

(1) Green Led - https://www.adafruit.com/products/300

(1) Red Led - https://www.adafruit.com/products/297

(1) 2.2k ohm resistor 10k ohm resistor (1) 1M ohm resistor (2) 560 ohm resistor

(1) 1 Perfboard (the size will be depend on the model fro this

(1) 1 batter pack holder and batteries

(2) 4'' x 24'' pieces of basswood

Step 2: Programming the Pro Trinket

This section will continue to follow, "The Secret Knock Door Detector" Instructable. The original code and project used a DC motor, so I had to change the code to run a stepper motor.

This section requires you to open Arduino software, compile and upload a sketch.

#1: DownloadDownload the file secret_knock_detector.pde at the bottom of this section and copy it to your sketchbook. (Or view the text and cut and paste it into a new sketch.)(Tip: If the name of the downloaded file is something like "BARS5HS13H8SW.tmp" simply rename it to secret_knock_detector.pde. and you're good to go.)

#2:Open the sketch and compile it. It should compile properly the first go, but it's good to be sure.

#3:Connect your Arduino and upload the sketch.If you have any trouble, check the troubleshooting section at the Arduino site.

Code overview:

about Line 28: const int threshold = 4; This is the sensitivity of the knock detector. If you get a lot of noise, raise this (up to 1023), if you're having a hard time hearing knocks you can lower it (as low as 1).

about Line 29: const int rejectValue = 25;

about Line 30: const int averageRejectValue = 15; Both of these are used to determine how accurately someone has to knock. They are percentages and should be in the range of 0-100. Lowering these means someone must have more precise timing, higher is more forgiving. averageRejectValue should always be lower than rejectValue. Settings of about 10 and 7 make it hard for two people to knock the same knock even if they know the rhythm. But it also increases the number of false negatives. (ie: You knock correctly and it still doesn't open.)

about Line 31: const int knockFadeTime = 150; This is a crude debounce timer for the knock sensor. After it hears a knock it stops listening for this many milliseconds so it doesn't count the same knock more than once. If you get a single knock counted as two then increase this timer. If it doesn't register two rapid knocks then decrease it.

Step 3: Step 3: Lay Out and Test the Circuit

This is the last section that references "Secret Knock Detecting Door Lock"

I have included a wiring diagram of his Secret Knock. It can serve as a helpful guide, but do not worry about the programming switch or dc motor. If you plan to use the stepper motor, like I did, then follow the stepper motor steps below.

We're going to go slowly and check as we go.

#1: Wire the Piezo Sensor

Solder a pair of 12" (30cm) leads to the Piezo speaker. Connect it between Analog pin 0 and the ground. Also attach the 1M ohm resistor between Analog pin 0 and the ground.Test: With your Arduino plugged into your computer (via USB or Serial cable) and open the Serial Montor window. (That's the button furthest to the right at the top of the Arduino development environment.) With the Arduino powered on you should see the text "Program start." Tap the piezo speaker and you should see the text "knock starting" and "knock" each time you tap it. Stop for a second or two and you'll probably see "Secret knock failed" or "Door unlocked!"

#2: Wire up the LEDs

Wire up some LEDs so we don't have to use a serial cable to see what's going on.Connect the red LED to digital pin 4 and green LED to digital pin 5 with their corresponding 560* ohm resistors in line.Test: If you power the circuit the green LED should light. If not, check your connections and make sure the LED is the right way around. Every time you tap the green led should dim. After tapping the correct sequence the green led should blink a few times. Tapping the wrong sequence should blink the red one. If none of this happens, check the polarity on your LEDs and all of your connections.

#4: Wire in the stepper motor and driver

Connect to Arduino
Vmotor to 5V

Vcc to 5V

GND to ground

AIN2 to Digital 8

AIN1 to Digital 9

BIN1 to Digital 10

BIN2 to Digital 11

PWMA and PWMB to Vcc

Connect to Stepper Motor

Blue and Yellow wire to Motor A

Pink and Orange wire to Motor B

Step 4: Adjusting Stepper Code

Serial.println("Forward");

stepper.step(1000); This number adjust how many times the stepper motor rotates forward

delay(4000);

Serial.println("Backward");

stepper.step(-1000); This number adjust how many times the stepper motor rotates backward

Step 5: Build the Box

I chose to laser cut the sections of the box. The design is pretty simple and cutting the pieces can also easily be done with basic wood shop tools. I have included the Illustrator file below.

After the pieces are cut they can be attached together with wood glue.

Step 6: Putting It Together

I 3d printed a coupler to attach the stepper motor to the threaded rod. If you do not have access to a printer they make commercial couplers.

I used threaded rod to attach the pieces that would have movement. The three rods on the outside are for stability. The one rod in the center is what allows the top box to move up and down. Cutting the holes a couple millimeters larger than the rod is what allows The Tippy to wobbly back and forth.

Step 7: Add Paint If You Desire

Once you assemble all the parts you can paint it and maybe even add a decal or two!