Overview

You can build your own model garage with a functioning automatic garage door powered by a Circuit Playground Express, servo motor, and pushrod mechanism created with a paperclip, cardboard, a dowel, and a straw!

You'll code the Circuit Playground Express using MakeCode so that it can open or close your garage door at the press of a button, and even build a light activation mode that will automatically open the door for you!

Parts & Materials

For materials, you'll need:

  • small, corrugated cardboard box
  • drinking straw
  • wooden dowel or bamboo skewer
  • paper clip.

The electronics you'll need are listed below.

1 x Circuit Playground Express
Incredibly awesome microcontroller board
1 x Standard servo
TowerPro SG-5010

Tools

Here are the tools you'll use to build the project:

  • Hobby knife
  • Metal ruler
  • Hot melt glue gun and hot melt glue -- either low or high temperature is fine
  • Pencil
  • Small pair of pliers for paper clip bending (optional, you can do it with your fingers too!)

Pushrod Mechanism

To open the garage door we'll make a mechanism that transfers the rotation of our servo to the rotation of the door.

We could try to mount the door directly to the servo's shaft, but this would be a bit tricky, and pretty bulky looking.

Instead, we'll transfer the rotation of the servo over a short distance using a pushrod made from a paperclip.

Take a look at the diagrams below -- there are a few key things to note:

  • The servo shaft rotates clockwise, and the servo arm rotates along with it
  • The pushrod translates (moves) to the right and slightly down as it is pushed by the servo arm
  • The pushrod pushes the door's control horn to the right
  • The door is on a hinge (made from a drinking straw) which rotates counterclockwise around the door pivot dowel

Later in the guide, we'll build a similar mechanism for our garage.

Code it with MakeCode

You can code your Circuit Playground Express using MakeCode to open and close with buttons presses and also using the light sensor! If you aren't already familiar with MakeCode, check out this guide to get started, then return here when you're ready.

Functions

Here's what we will set up the Circuit Playground Express to do:

  • Open the garage door by turning the servo when the A button is pressed
  • Close the garage when the B button is pressed
  • Watch for a bright light on the light sensor
    • When a bright light is detected, open the door, wait five seconds, and then close the door

Those are the basics, but we'll also get fancy and set up some lights and sounds to accompany these functions.

On Start

First, we'll set up some things that happen as soon as the program starts. Begin by dragging an on start block from the LOOPS category into your program canvas area.

Place a set all pixels to block into the on start block, and change the color to orange. This will be the color of the NeoPixel ring on the Circuit Playground Express when the program starts.

It's also nice to have a startup sound. Pull in a play tone at block. Change the note to High A and the duration to 1/2 beat.

Variables

Since we'll be setting open and closed values for the servo angles multiple times in the program, it's helpful to set up a couple of variables with these numbers which we can then use over and over again.

From the variables category click Make a Variable... and then create one and name it 'closed'. Repeat this a second time for one called 'open'.

Drag in a block called set closed to into the on start loop. Then duplicate this block and change the drop down menu to the open variable.

You may need to adjust these values later but for now use 170 and 70 as shown here.

Servo Write

We'll have the servo automatically go to the closed position when the program starts.

From the pins category, drag in a servo right block. Change the pin from the default A1 to A2. (You can use either of these two pads on the Circuit Playground Express to control a servo.)

Then from the variables category drag in closed variable into the servo right pin block.

Light it Up

From the input category drag in the light threshold block. Change the first drop-down item from dark to bright. Then set the value to something pretty high such as 240. This will vary depending on how bright the light source is that you want to use to open the garage door.

Lights Out

Finally we will turn off all of the NeoPixel LEDs by dragging in a set all pixels block from light category, and then changing the color value to black.

Buttons

Next we will set up the Circuit Playground Express so that pressing the A button will sound a tone and open the garage. We will set up to the B button to close the garage.

Create a set of blocks just like the ones shown in the image below.

Light Sensor

Finally, we will set up a light sensor block so that when a bright light is detected the following actions occur:

  • The LEDs will turn blue
  • A melody will play
  • The servo will open the door.
  • Then an animation will play for five seconds, giving a toy car time to pull into the garage
  • The lights will change to red
  • A different melody will play
  • The door will close
  • The LEDs will turn off

Add the blocks needed to do these actions, as shown in the block set below.

Your program is complete! There's an interactive embedded version of it below. You can now download your program from your MakeCode session, press the reset button on your Circuit Playground Express, and drag the program onto it.

You're ready to test it out!

Build the Garage

A small cardboard box will make for the perfect garage for your die cast cars or small robots. We'll make the garage and add the door mechanism next.

Cut Out the Box Floor

  • First, cut the flaps off of the bottom of the box. This way your table top or floor will be the garage's floor too
  • Save the cutoffs, you'll use some cardboard scraps later to build a door control horn

Make the Door

  • To make the door, flatten the box and mark the shape with a ruler and pencil. Then, cut out the door section
  • Glue the straw onto the inside of the door (you can cut it to length first) at a point 1-1/2” from the bottom edge

Pivot

The door and straw will pivot around the dowel.

  • Place the dowel through the straw
  • Align the door with the opening in the wall and mark the position of the dowel. You'll use this to cut two small holes in the walls for the dowel
  • Mark and cut two small holes on either wall that meets the door cutout wall as shown
  • Feed the dowel through one wall, then into the straw, and out the other side

Test out the opening and closing action -- if the fit is too tight it may be hard for the servo to push the door open, so you can trim away a bit of the opening if necessary.

 

Servo Mounting

  • Place the servo on the box in a position where its shaft is level with the door hinge pivot, and mark its location with a pencil
  • Carefully cut out the opening so the servo will fit through and then push it through from the inside as shown. A snug fit will help it stay put, but you can also add some more cardboard support later if needed

Control Horn

  • Cut two small pieced of cardboard to act as a mounting point for the pushrod we'll be making
  • Fold and glue one piece as shown and them mount it to the door below the dowel as shown
  • Glue the second piece to the mount -- this is our control horn, when it gets pushed by the pushrod it will cause the door to swing upward on its hinge

Now, glue the horn mount to the inside of the door as shown.

We'll poke some holes through the control horn to connect with the pushrod. The different hole positions will allow us to fine tune the pushrod placement later.

Pushrod

  • Straighten out a paper clip to create the pushrod
  • To connect with the servo arm, you can make a small z-shaped bend as shown and then fit it into the farthest hole of the arm
  • Press the arm onto the servo shaft so that the pushrod arm points straight up -- this will be the door's closed position. You should try twisting the horn back and forth to make sure the shaft doesn't hit its limits before you need it to. It should be almost fully counter-clockwise when you fit the arm on pointing straight up
  • Now, you can check the length of the pushrod -- note where it will need to bend at a right angle to go through the control arm. Bend the rod and then push it through one of the holes in the control horn
  • Test the throw of the pushrod by rotating the servo about 90 degrees as shown here

Roof

  • Close the roof flaps and tape or glue them down into place
  • Flip the garage upside down and take a look at the angle of the pushrod from the servo arm to the control horn -- you can fine tune it for better performance by adding a small angled bend as shown here
  • One of the nice things about paperclip pushrods is that you can make small adjustments by hand easily in order to get the door to open just right!

Turn the servo to the clockwise position and make sure the door swings open. If it doesn't, or has difficulty, you can adjust the position of the pushrod in the control horn by poking additional holes as "lower" or "higher" positions until it works smoothly.

Circuit Playground Express Controll

Now, connect the Circuit Playground Express to the servo with this wiring:

  • CPX VOUT to servo orange power
  • CPX GND to servo brown ground
  • CPX A2 to servo yellow signal

Plug in the USB cable to power the Circuit Playground Express and test it out -- push the A button and it opens! B and it closes!

You can do a couple of things to improve the motion if you're having any problems -- tweak the values of open and close in the MakeCode program, and adjust the pushrod.

You can use some masking tape or double stick foam tape to mount your Circuit Playground Express on the garage wall next to the door.

Grab a flashlight and shine it at the light sensor. I opens automatically!!

Have fun with your brand new garage. You can now cut out some additional windows, decorate it, and maybe think about additional automation and lighting you can build for it. A "neon" sign would look rad.

This guide was first published on May 13, 2018. It was last updated on May 13, 2018.