Overview

The swing ride or "chair o planes" is a popular and famous ride at carnivals and amusement parks. The ride uses centrifugal force to lift you up and up as you spin faster! We get to make one with lights, music and more with the help of CRICKIT and cardboard.

circuitpython_chairoplane_wiki.jpg
image: Wikimedia Commons

Prerequisite guides:

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

Adafruit Parts

1 x Adafruit CRICKIT for Circuit Playground Express
Crickit: Creative Robotics and Interactive Construction Kit is an add-on to Circuit Playground Express
1 x Circuit Playground Express
Circuit Playground Express is a great introduction to electronics and programming
1 x TT Motor DC Gearbox
200 RPM 3 to 6VDC
1 x USB Cable
USB A to Micro-B
1 x Switching power supply for CRICKIT
5V 2A (2000mA) - UL Listed
3 x M3 Screws - 25mm long
Mounting screws for mounting motor to base
3 x M3 Hex Nuts
For mounting motor to base

Materials and Tools

  • Paper towel or aluminum foil roll cylindrical cardboard center 
  • Medium-sized cardboard box - need at least one face of box to be 25 x 25 cm (to make the circle top)
  • Scrap pieces of cardboard (to make swings and character cutouts)
  • Small cardboard box for mounting components to (Adafruit one works well)
  • Pencil
  • Ruler
  • Hobby knife
  • Scissors
  • Twine or string
  • Thumb tack
  • Hot glue gun + 2-3 sticks of glue
  • Phillips head screwdriver
  • Tape

Optional but recommended: 

  • Cutting mat (for cutting cardboard)
  • Level (for leveling ride, reducing wobbles)
  • Glue stick (for character cut outs)
  • Glitter glue
  • Popsicle stick (to spread glitter glue)
  • Plastic jewels
  • Other decorations!
  • Peel and stick hoop and loop fasteners (Velcro) - For attaching characters to swings
  • Print out of characters

Swing Structure

First up, we'll build the structure of the swing ride, starting with the circular top.

  • Cut out one of the faces from your medium-sized cardboard box. The face should be at least 25 x 25 cm.

  • Cut a piece of twine or string about 18cm long, tie it to the thumb tack, tie the other end of the string to a pencil. The distance from the tack to the pencil should be roughly 10 cm.

  • Use the string, tack and pencil to draw a circle on the cardboard. (Note: you may need to put an extra piece of cardboard under the thumb tack to make more steady when drawing circle)

  • Use a ruler to draw perpendicular lines going through the center of the circle.

  • Use a hobby knife to cut out the circle.

Prepare and measure circular top

  • Measure the diameter of your cylindrical base. The paper towel roll piece I used was roughly 4.4 cm in diameter.

  • From the center of the circle top, draw a mark that is half the diameter of your cylindrical base on all 4 lines.

  • Take your cylindrical base and make sure it fits right in with the marks you drew.

  • Lastly measure the distance from the edge of the circle top to the mark you just drew, divide by two and place a mark. Repeat on 3 other lines.

Make the swing tops

  • Cut (4), 5 cm pieces of string.

  • Cut (8), 20 cm pieces of string.

  • Cut out (4) 2X4cm pieces of cardboard.

  • Make a mark in the center of each of piece of cardboard on one side and two marks equidistant from each other on the other side.

  • Use a glue gun to glue the shorter strings to the marks made on the circle top.

  • Now glue the cardboard pieces to the string using the center mark you drew.

  • Glue the long strings to the equidistant marks you drew on the cardboard pieces.

* Tip: when gluing string or twine, it helps to bend the end you are gluing then glue down the entire bent portion of the string

Finish the swings

  • Cut out (4) 4 x 8 cm cardboard pieces

  • Cut out (4) 4 x 4 cm cardboard pieces, then cut each one diagonally so you have (8) 4 x 4 x ~5.66 cm pieces

  • Score one side of the larger pieces to fold at 90 degree angle.

  • Glue one of the smaller pieces on each side of the bent piece.

  • Glue string ends to chairs.

 

* Note: when gluing string ends to chairs, be aware of differing string lengths which may how upright each chair might sit naturally.

 

 

Attach cylinder and motor base wheel

  • Center the cylinder in the middle of marks drawn earlier and glue in place.

  • Center the motor wheel on the other end and glue in place.

  • Reenforce glue along the wheel and cylinder for a strong, sturdy connection.

Mounting

Prepare the mounting box

  • Find the center of mounting box and draw a mark (if using Adafruit box, use the bottom of the box for mounting).
  • Take a pencil or pen and create a hole.

  • Place the motor down on hole with cables facing up. Place some pressure on the motor.

  • Create another hole where the cardboard is imprinted from the bottom piece of the motor.

* Note: These holes will be used to stabilize the motor to make it easier to mount in place.

Mount the motor!

  • Screw in one of the M3 screws to one side of the motor.

  • Fasten with hex nut on the back (inside of box).

  • Repeat with other side and end of motor.

* Tip: a pair of pliers is a big help when fastening a small hex nut 

Now attach the swing structure to the motor on the base! LOOKIN' GOOD.

Leveling

  • Use a level on the circle top to see how level the swing ride is.

  • If it needs some adjusting, you can toss a small piece of cardboard under the motor to counterbalance the tilt.

  • You may have to temporarily unscrew some of the mounting screws to insert the cardboard piece.

Wiring

  • Attach the red wire (5V) from the motor to the outside pin on motor terminal 1. 

  • Attach the black wire (GND) from the motor to the inside pin on motor
    terminal 1.

  • Wire the speaker to the CRICKIT (wire orientation doesn't matter here).

  • Use a small knife like a multi-tool to screw in screws and secure wires in terminals.

  • Orient CRICKIT so that the capacitive touch pads are facing you. 

  • Use tape to secure the speaker and CRICKIT in place on box base.

Getting there!

Now that we have everything built and wired up, it's time to make it spin!

If you are new to programming I suggest using MakeCode which is an awesome introductory platform for learning to program,

If you have some experience or are up for a challenge try out the CircuitPython code!

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.

Install the MakeCode CRICKIT Extension

Before we start programming, let's make sure you have the CRICKIT extension installed in MakeCode.

Detailed instructions on how to do that can be found in this guide.

Create a New Project with MakeCode

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

 

The Code

What's going on in the code above?

  • When button A is clicked:
    • the brightness of the NeoPixels is set to a value of 134
    • all NeoPixels are set to a magenta color
    • the motor is selected for motor pin 1 and is set to 13%
  • When button B is clicked
    • the brightness of the NeoPixels is set to a value of 134
    • all NeoPixels are set to a blue color
    • the motor is set to stop with 0%

*Note: the % value of the motor can be negative if you wish for the swings to rotate the opposite direction. Switching the wiring of the motor will have the same effect. 

Uploading the code

Now that we have the code for the project, we need to upload it to the Circuit Playground Express.

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 Circuit Playground Express to your computer via the usb cable. Click the Circuit Playground Express 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.

Power up CRICKIT

Connect CRICKIT to power with the 5V DC power cable

The code should now be running so try it out!

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

Try changing the % value of the motor to various values and see what happens!

CircuitPython

Are you new to using CircuitPython? No worries, there is a full getting started guide here.

If using MakeCode previously, you'll have to go back to switch to CircuitPython mode. Find out how to do that here.

To edit the CircuitPython code and receive realtime feedback in the REPL, Adafruit suggests using the Mu Editor. You can learn about Mu and installation in this tutorial.

If you haven't used Circuit Playground Express with CRICKIT before, make sure you've updated it with the latest special 'seesaw' version of the CPX firmware. This guide will show you how.

Open up the Mu editor or an editor of your choice with a REPL.

Full Code

Download the code below or copy and paste into Mu and save as code.py on the CIRCUITPY drive.

# Isaac Wellish
# Code adapted from Mike Barela's Hello World of Robotics and
# Make it Move with Crickit guides at learn.adafruit.com
# Power must be plugged into right side of motor 1 on CRICKIT
#  to turn counter clock wise

import time
import audioio
import board
import neopixel
from digitalio import DigitalInOut, Pull, Direction
from adafruit_crickit import crickit

# Set audio out on speaker
speaker = audioio.AudioOut(board.A0)

# Two onboard CPX buttons for input (low level saves memory)
button_a = DigitalInOut(board.BUTTON_A)
button_a.direction = Direction.INPUT
button_a.pull = Pull.DOWN

button_b = DigitalInOut(board.BUTTON_B)
button_b.direction = Direction.INPUT
button_b.pull = Pull.DOWN

# Create one motor on seesaw motor port #1
motor = crickit.dc_motor_1

# NeoPixels on the Circuit Playground Express Light Blue
pixels = neopixel.NeoPixel(board.NEOPIXEL, 10, brightness=0.7)
# Fill them with our favorite color "#0099FF light blue" -> 0x0099FF
# (see http://www.color-hex.com/ for more colors and find your fav!)

# set pixels to blue on start up
pixels.fill(0x0099FF)

motorInc = 0

# Start playing the file (in the background)
def play_file(wavfile):
    audio_file = open(wavfile, "rb")
    wav = audioio.WaveFile(audio_file)
    speaker.play(wav,loop = True)

while True:
    if button_a.value:
        pixels.fill(0xFC4044)
        play_file("circus_chair.wav")       # play WAV file
        motor.throttle = -0.20
        time.sleep(0.2)
        motor.throttle = -0.11 + motorInc  # increase speed
        motorInc -= 0.01

    if button_b.value:
        speaker.stop()
        pixels.fill(0x0099FF)  # magenta
        i = motor.throttle
        while i < -0.05:
            i += 0.005
            motor.throttle = i    # slow down!
            time.sleep(0.1)
        motor.throttle = 0 # stop
        motorInc = 0

Import Libraries and Initialize Values

We'll begin the program by importing the necessary libraries and initialize the variables we'll be using.

If you think you might be missing a library, you'll be covered by installing the whole library package. Find out how in the CircuitPython Essentials Guide on CircuitPlayground Libraries.

Download: file
    import time
import audioio
import board
import neopixel
from digitalio import DigitalInOut, Pull, Direction
from adafruit_crickit import crickit
 
# Set audio out on speaker
speaker = audioio.AudioOut(board.A0)

# Two onboard CPX buttons for input (low level saves memory)
button_a = DigitalInOut(board.BUTTON_A)
button_a.direction = Direction.INPUT
button_a.pull = Pull.DOWN
 
button_b = DigitalInOut(board.BUTTON_B)
button_b.direction = Direction.INPUT
button_b.pull = Pull.DOWN 

# Create one motor on seesaw motor port #1
motor = crickit.dc_motor_1

# NeoPixels on the Circuit Playground Express Light Blue
pixels = neopixel.NeoPixel(board.NEOPIXEL, 10, brightness=0.7)
# Fill them with our favorite color "#0099FF light blue" -> 0x0099FF
# (see http://www.color-hex.com/ for more colors and find your fav!)

#set pixels to blue on start up
pixels.fill(0x0099FF)


motorInc = 0
  

Set up and initialize speaker, buttons, motor and NeoPixels.

Adding Music

The music for this project was provided by robcro6010 on freesound.org a "huge collaborative database of audio snippets, samples, recordings, bleeps, ... released under Creative Commons licenses that allow their reuse"

CircuitPython needs sound files formatted a certain way to play them. See this guide for ensuring your sound files are in the correct format.

Here is a properly formatted .wav file of the music we are using. Click to download:

Once you have the file, place it in the top level (root) directory in your Circuit Playground Express CIRCUITPY drive.

Function for playing .wav files

Download: file
# Start playing the file (in the background)
def play_file(wavfile):
    audio_file = open(wavfile, "rb")
    wav = audioio.WaveFile(audio_file)
    speaker.play(wav,loop = True)

This code searches for a .wav file on the drive, plays and loops it.

Main Loop

Download: file
while True:
    if button_a.value:
        pixels.fill(0xFC4044)  # magenta
        play_file("circus_chair.wav")       # play WAV file     
        motor.throttle = -0.20
        time.sleep(0.2)
        motor.throttle = -0.11 + motorInc  # increase speed!
        motorInc -= 0.01
               
    if button_b.value:
        speaker.stop()
        pixels.fill(0x0099FF)  # blue
        i = motor.throttle
        while i < -0.05:
            i += 0.005                    
            motor.throttle = i   # slow down!            
            time.sleep(0.1)          
        motor.throttle = 0 # stop 
        motorInc = 0

The while True: loop will be running forever once the program has entered it.

When Button A is pressed:

  • NeoPixels turn magenta
  • start the music
  • set the motor to value of -20 to get torque needed to start moving
  • quickly set motor to -0.11 which will be slowest speed
  • decrement motorInc by 0.01
  • each time Button A is pressed again, the motor will increase in speed by 0.01

When Button B is pressed:

  • stop the music
  • turn NeoPixels blue
  • decrement motor speed over time until motor stops

* Note the values for the motor are negative because I wanted the ride to spin counter-clock wise. I could have also changed the orientation of the motor wires in CRICKIT.

There you have it! 

 

Troubleshooting:

  • If the music isn't playing, make sure the file is formatted correctly and that the file is in the top level (called the root) directory of the CIRCUITPY drive.
  • Use the REPL in Mu to tackle code related issues.
  • More CircuitPython help here.
  • If having motor problems, check that you have a 5V power supply attached to the DC jack on your CRICKIT board and that the on/off switch next to the power jack is in the on position.

Decorations and Characters!

Glitter Greatness

  • Glob the glitter glue all over the cylinder.

  • Use a popsicle stick to uniformly transfer the glitter all over the cylinder.

  • Follow the swirl of the cylinder with another color of glitter glue to create a "barber shop" effect.

  • Let the glue and glitter dry overnight.

Bedazzled

  • Attach some plastic jewels or other decorations to the perimeter of the circle top.

  • Create a pattern and repeat all the way around the top. 

Adding Characters to Ride!

Click the button below to download a pdf of the characters used in the project. Or make your own!

  • Cut out character with scissors and glue to cardboard.

  • Cut out character from cardboard with hobby knife.

  • Cut out (4) 2 x 3 cm pieces of cardboard to glue to bottom of characters as a stand.

  • Cut out (8) 2 x 3 cm pieces of hook and loop tape (4 pieces of hook and 4 pieces of loop).

  • Place one hook piece on bottom of character.

  • Place the loop piece on a chair.

  • Repeat for all characters.

 

* Tip: Cut out character with scissors completely before glueing to cardboard and cutting out with hobby knife. Will end up more clean looking. 

Look at those Hooligans!

Adding Fruit Power

  • Cut out Adafruit logo using method from above.

  • Glue upright to center of circle top.

  • Add some glittery goodness!

Final Touch: Orient the Swings

You may find the swings do not all face one direction when done.

If you want to orient the swings to all face one direction:

  • Use a hot glue gun to put some glue on the small string at the top of the swing.

  • Twist and hold swing until the orientation is just right.

Enjoy your new swing ride & cardboard buddies!

Swing awaaaaaayyyyy!

This guide was first published on Oct 28, 2018. It was last updated on Oct 28, 2018.