Maker.io main logo

Celebrate New Year's Eve with the Circuit Playground Express Drop

2018-12-27 | By Maker.io Staff

License: See Original Project Circuit Playground

For New Year’s Eve you can make your own Countdown like the New York City Times Square Ball Drop. With the Circuit Playground Express you can celebrate in the comfort of your own home.

Courtesy of Adafruit

Guide by Isaac Wellish

Overview

 

Drop into the new year with a blinged out Circuit Playground Express!

This guide will show how to build a simple drop mechanism that mimics the famous Times Square Ball Drop on New Year's Eve in New York City.

Programming this celebrative project is easy using Microsoft MakeCode, a drag and drop interface and language that requires no prior programming experience!

Figure-1

Source: Wikimedia Commons

Prerequisite guides

Reading or at least skimming through these guides before beginning will save you some time in the future. You can always refer back to them if you need help!

Adafruit Parts

Optional but recommended:

Tools and Materials

  • Medium to large width corrugated cardboard - need at least 1 sheet sized 22 cm X 14 cm
  • Scrap pieces of cardboard (to make spool and mount)
  • Paper towel or aluminum foil roll center
  • Pencil
  • Ruler
  • Hobby knife
  • Scissors
  • Hot glue gun
  • Twine or string
  • Thumb tack
  • Duct tape
  • Glue stick
  • Mini bamboo skewers

Optional:

  • Cutting mat (for cutting cardboard)
  • Construction paper, glitter glue, foil door curtain (for decorations)
  • Popsicle stick for spreading glitter glue.

Program with MakeCode

What is MakeCode?

MakeCode is a web-based code editor for physical computing made by Microsoft.

What does that mean for you? It means you can program your Circuit Playground Express to do almost anything you can dream up right from a website! You can code with blocks similar to the language Scratch, or you can do more advanced coding with Javascript. We'll be sticking to the block-based programming for this project.

More on MakeCode for Adafruit boards here.

Create a New Project with MakeCode

Head over to https://makecode.adafruit.com/ and create a new project.

Click the button below to access the code for this project.

Click Here to Open the Project in MakeCode

Figure%20-2

What's going on the code above?

Figure-3

  • On start, set the volume of the CPX speaker, set the variable play to 0, then set all the NeoPixels to red.
  • In a forever loop, we check to see if the variable play is set to 1. If it is, call the song function to play the tune "Auld Lang Syne" then set play to 0. As it's a forever loop, this code block loops forever regardless of other events that happen in the code!

Figure-5

  • An abbreviated version of the song The "Auld Lang Syne" can be separated into 2 parts. The tune starts with part 1, then goes to part 2, before repeating again. Creating functions for these song parts then "calling" the functions later allows us to have much cleaner looking and more organized code. It also allows us to reduce the amount of code needed for the project making the program more efficient (more on that in the next code block).

Figure-5

  • When the CPX is shaken, we call the function countingdown, set the variable play to 1, turn the NeoPixels rainbow, turn the servo clockwise for 3 seconds, pause the servo for 15 seconds, turn the servo counter-clockwise for 3 seconds then turn the NeoPixels back to all red.
  • In the countingdown function, we want to count the NeoPixels down one at a time, per second, from all red to all white. To do this with out making the code clunky, we can use something called a while loop. First, the NeoPixels are set to all red, then the variable countdown is set to 9. In the while loop, as long as the variable countdown is greater than or equal to 0, each concurrent NeoPixel will change from red to white, every second. In each iteration of the loop, countdown is decremented by 1 until it reaches -1 at which point the program will exit the function and continue with the rest of the code to play the song and turn the servo.
  • In the on shake code block, the piece of code that says "Servo write pin A1 to (value between 0 and 180)" determines how fast or slow and what direction the servo spins. Values between 0 and 90 spin the servo clock wire and 90 - 180 is counter clockwise. The closer the values are to 90, the slower the servo will spin in either direction.

Uploading the Code

Now that we have the code for the project, we need to upload it to the CPX.

Let's name our file and download it.

  • Choose a name at the bottom of the page.
  • Then click the pink Download button.

Follow the directions and connect your CPX to your computer via the usb cable. Click the CPX Reset button once to go into programming mode (all NeoPixels will turn green).

In some cases, you may need to press the reset button twice to get into programming mode.

Next, look for the file in your downloads folder and drag it onto your CPLAYBOOT drive that should have showed up in your file manager/finder when you plugged in your board and entered programming mode.

You should now see the CPLAYBOOT drive disappear.

The code should now be running and the NeoPixels should be all red. Before we test it out let's wire up the servo!

Wire Electronics

Figure-6

Before we build the mechanism we'll first wire up the electronics to make sure everything is working correctly. This will also help us get a handle on how the electronics will work in tandem with the cardboard and string components.

Figure-7

Figure-8

  • Take the continuous servo's cable and plug in corresponding cable to CPX: Orange/yellow goes to A1 on the CPX, red to VOUT, brown/black to GND*
  • Connect the battery to the CPX via the JST connector.

* If you have the alligator clip to jumper wires this will be possible. If you only have wires, skip ahead to "Prep and Mount Electronics" section for how to wire the project with these components. I didn't have those specific components so I used alligators clips and attached them to jumper wires which works just fine as well for testing out the electronics.

The code should now be running so try it out!

  • When the board is powered up, the NeoPixels on the CPX should turn red.
  • When you shake the CPX, the NeoPixels should begin counting down turning clock-wise from red to white one NeoPixel every second.
  • When the last NeoPixel turns white, NeoPixels turn into a rainbow pattern, the servo turns for 3 seconds and the "Auld Lang Syne" song comes on.
  • After the servo is done turning the CPX should continue playing the song with rainbow NeoPixels until the song finishes.
  • After a couple more seconds, the servo should turn the other way for about 3 seconds, then the NeoPixels should turn red again ready to restart the process.

If you are having issues getting things to work check out this extended guide here.

Build the Base and Mount

Figure-9

Using hobby knives or other sharp cutting instruments should be supervised for younger Makers.

Figure-10

Figure-11

  • Use a hobby knife or box cutter to cut out a sheet of cardboard sized 22 cm X 14 cm.
  • Glue a paper towel roll center to one end of cardboard sheet.
  • Cut (or break with hands) a bamboo skewer to be roughly 17 cm long. Keep the pointy side as part of the piece.
  • Glue on top of the roll center with the pointy side facing towards the length of the sheet. Leave a couple of centimeters of skewer to hang off the back.

Figure-12

Figure-13

Figure-13a1

  • Use a string, a thumb tack and a pencil to draw a circle on some cardboard with a diameter of 8 cm. Tie the string to the thumb tack then measure a distance of 4 cm from the tack to a pencil and tie around pencil tip. Use the tack to guide the pencil around a circle. You may need to lay some extra cardboard underneath so that the tack can firmly rest in the cardboard without moving too much.
  • Next, measure and draw two small rectangles sizes 2 cm X 3 cm.Use a hobby knife to cut out these pieces.
  • Orient the servo so that the brown wire is facing upward. Glue the small rectangular pieces on the sides of the servo with the 3 cm lengths sticking out.

Make the Spool

Figure-14

Figure-15

Figure-16

  • Measure and draw a rectangle on some cardboard sized 1 cm x 8 cm. Draw a line at every 2 cm point along the rectangle.
  • Measure and draw a circle with a 4 cm diameter using the same string and thumb tack technique from earlier.
  • Cut out the parts.
  • On the rectangular piece, score along 2 cm lines.
  • Bend and fold into square and glue onto one circle piece.
  • Glue the other circle on top. Figure-17
  • Cut a string roughly 45 cm long and glue one end to spool.
  • Wrap the string around the spool.
  • Glue servo wing on the side of the spool making sure the spool is oriented such that the string is coming up and out to the right.

Figure-18

  • Draw perpendicular lines through each side of the 8 cm circle.

Figure-19

Figure-20

  • Attach servo onto wing and spool.
  • Orient the spool and servo contraption on the 8 cm circle base such that the spool is centered. Double check that the string is facing towards the circle base top where it will be pulled through shortly.
  • Glue down spool and servo contraption on circle base.
  • On the front of the circle base, use a hobby knife to cut a hole in the top center.
  • Pull spool string through hole.

Prep and Mount Electronics

Figure-21

Figure-22

Figure-23

  • Use wire strippers to remove 1-2 cm of wire wrap from ends of each wire.*
  • If using stranded core, twist wires together.

*I used jumper wires because solid core wires we're unavailable but the process is the same!

Figure-24

Figure-25

  • Pull black wire through GND and twist around to create a tight connection.
  • Repeat with red wire to VOUT and yellow to A1.
  • Connect other ends of wire to servo cable. Yellow/A1 to orange, red/VOUT to red, black/GND to brown.

Figure-26

Figure-27

  • Put piece of duct tape in center of front side of circle base.
  • Place CPX in center of tape.
  • In order to counter balance the weight from the servo and spool which are on the right side of the back of the circle base, we need to place the battery on the other side.
  • Put a piece of tape on the left side of the back of the circle piece and place the battery down with the wires facing the bottom.
  • Gather / organize wires together and tape down.

Figure-28

  • Insert JST connector from battery into CPX.
  • Loosely tie a knot in the string.
  • Place skewer though hole of knot and pull tight.

Test it out!

Try shaking the CPX and see what happens. If the CPX doesn't fall/rise enough or falls/rises too far, go back to MakeCode and edit the on shake code block. Remember, the piece of code that says "Servo write pin A1 to (value between 0 and 180)" can be edited to change the speed of the servo.

Extra Decoration

Figure-29

Figure-30

  • Remove CPX from front of circle base.
  • Use a popsicle stick to spread glitter glue on the front of the circle base.
  • Remove some glue from the center where CPX will get taped back later.

Figure-31

  • Spread another color of glitter glue on the paper towel core. Two layers may be preferable.
  • Add whatever decorations you want! I followed the roll's line with a different color glitter glue.

Figure-32

Figure-33

  • Draw the block letter numbers of what ever year you are celebrating.
  • Cut 'em out.
  • Attach to glitter glue on front circle base.
  • Feel free to add glitter glue to the numbers if you'd like!

At this point you may want to let glitter glue dry over night!

Figure-34

Figure-35

  • Using some shiny door hanger material, glue to back of circle base so the pieces are hanging off.
  • Place the CPX back in the center and plug in the battery.
  • Holding the contraption up, cut off extraneous hanging pieces.

Tie to the skewer and let it drop!

Happy New Year!

Figure-36

制造商零件编号 3333
CIRCUIT PLAYGROUND EXPRESS
Adafruit Industries LLC
制造商零件编号 3517
CIRCUIT PLAYGRND EXPRSS BASE KIT
Adafruit Industries LLC
制造商零件编号 404080001
WIRE STRIPPERS
Seeed Technology Co., Ltd
制造商零件编号 3255
TEST LEAD GATOR TO TIP PLUG 6"
Adafruit Industries LLC
制造商零件编号 1311
HOOK-UP 22AWG SOLID - 6 X 25FT
Adafruit Industries LLC
制造商零件编号 2442
SERVOMOTOR RC 130 RPM 5V
Adafruit Industries LLC
制造商零件编号 102-1492-BL-F0100
CBL USB2.0 A PLG-MCR B PLG 3.28'
CNC Tech
制造商零件编号 17620
HOT GLUE GUN 25W WITH PLASTIC TR
Aven Tools
Add all DigiKey Parts to Cart
TechForum

Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.

Visit TechForum