Finish the Box

Now it's time to hook up the servo motor to the CPX and test out your code!

The servo has three wires joined to a 3-pin female connector. Plug the male header pins on the ends of the alligator clip wires into this connector. To avoid confusion, choose wires that match the color of the servo wires.

Next, attach the alligator clips to the CPX by clamping them onto these holes around the edge of the board:

  • Connect the red or orange middle wire from the servo to 3.3V on the CPX (or you can connect it to Vout)
  • Connect the black or brown wire from the servo to GND
  • Connect the yellow wire from the servo to A1

A simple way to remember this:

  • The red/orange wire carries power from the CPX board to the servo. (The V on the 3.3V pin stands for "voltage.")
  • The black/brown wire is the ground wire that completes the circuit so current can flow. (GND means "ground.")
  • The yellow wire will carry the signal from the pin that you program -- in this case, Pin A1 -- so the CPX can tell the servo what to do.

If the servo wires don't reach the CPX, use female/male extension jumper wires to make them longer.

Check the Lid Opening Mechanism

Test out your code to be sure it does what you want it to.

One issue you may find is that the servo arm extension hits the lid with a loud noise and the lid bounces.

You can dampen both effects by putting some padding on the lid where the arm hits it. A piece of peel-and-stick craft foam works well.

Display Suggestions

To make the box open, you want the person to move their hand over the CPX. This will block the light, telling the light sensor to trigger the servo, sound, and lights.

For best results, you may want to place a desk lamp pointing down towards the CPX. That way, you'll know there will be a measurable difference between the light and the shadow of someone's hand.

How can you trick someone into reaching out over the CPX without tipping them off that something is about to startle them? One idea is to draw a fake-looking button and write "Press Here" on it. Tape it to the lamp or somewhere that will make the person reach across the control box and block the light. They probably won't even reach the button before the lid flips open and the CPX starts playing its song!

This guide was first published on Oct 08, 2019. It was last updated on 2019-10-08 16:28:32 -0400. This page (Finish the Box) was last updated on Oct 17, 2019.