CPX Carousel

by Engineering Carousel in Circuits > Microcontrollers

89 Views, 0 Favorites, 0 Comments

CPX Carousel

Screen Shot 2023-12-06 at 1.22.12 PM.png

This device, powered by a CPX(circuit playground express), is a miniature carousel that spins, lights up, and plays music. The design consists of a CPX, 3D printed parts, a continuous micro servo motor, and a battery. It is a combination of thingiverse designs and custom pieces that have been 3D printed to create a working carousel.  The carousel is set on top of a hollow box to conceal most of the wiring and hardware, while the CPX is placed on the outside so the lights can be seen and it is convenient to press the buttons.

Supplies

3D Printing

263E2EAB-F632-403C-A909-A903F80D4DDA_1_201_a.jpeg
DA4D051A-49F6-4E43-8FAB-F6E6F73C2BB3_1_201_a.jpeg
C0509F57-6043-41AB-947D-9238941041D3_1_201_a.jpeg
  • Use thingiverse carousel design and print _ parts for the main carousel
  • Print base plate that will hold servo motor from TinkerCAD
  • Print Base cover from TinkerCAD
  • Print CPX holder from thingiverse

Parts that should be printed

  • Base plate
  • Base cover
  • CPX snap-fit holder
  • carousel cone
  • carousel top with spooks

Coding

The provided code will:

  • On button A spin fast with bright lights and play a sound
  • On button B spin opposite direction with dimmed lights
  • When switch is flipped on CPX it will stop all movement and show one color throughout

*code.py file provided below

while True:

  if cp.button_a: 

    "Button A pressed!"

    cp.play_file("rise.wav")

    cp.play_file("rise.wav")

    cp.play_file("rise.wav")

    cp.pixels[0] = (255, 0, 0)

    cp.pixels[1] = (255, 204, 0)

    cp.pixels[2] = (0, 255, 0)

    cp.pixels[3] = (0, 0, 255)

    cp.pixels[4] = (255, 0, 255)

    cp.pixels[5] = (255, 0, 0)

    cp.pixels[6] = (255, 204, 0)

    cp.pixels[7] = (0, 255, 0)

    cp.pixels[8] = (0, 0, 255)

    cp.pixels[8] = (0, 0, 255)

    print("forward")

    my_servo.throttle = 1.0

    cp.play_file("rise.wav")

    cp.play_file("rise.wav")

    cp.play_file("rise.wav")

  if cp.button_b:

    "Button B pressed!"

    cp.play_file("dip.wav")

    cp.play_file("dip.wav")

    cp.play_file("dip.wav")

    cp.pixels[0] = (0, 30, 179)

    cp.pixels[1] = (21, 0, 128)

    cp.pixels[2] = (10, 12, 0)

    cp.pixels[3] = (17, 10, 0)

    cp.pixels[4] = (17, 76, 9)

    cp.pixels[5] = (0, 26, 13)

    cp.pixels[6] = (0, 64, 12)

    cp.pixels[7] = (89, 0, 17)

    cp.pixels[8] = (85, 0, 10)

    cp.pixels[9] = (30, 0, 17)

    print("reverse")

    my_servo.throttle = -0.5

    print("Light:", cp.light)

    cp.play_file("dip.wav")

    cp.play_file("dip.wav")

  if cp.switch:

    cp.pixels.fill((128, 0, 128))

    print("forward")

    my_servo.throttle = 0.0

    time.sleep(4.0)

Assembly 3D Prints Connections

  • Glue the servo motor to the baseplate with the cord for connection through the given hole
  • Attach/glue the CPX holder to the base cover on the corner above the wiring hole
  • Glue the carousel cone to the top so that the spooks are facing down
  • Glue the servo horn to the bottom of the carousel cone

Assembly: Wiring

The servo is connected to the CPX using three wires that are brown, red and orange that are then connected to alligator clips. Each wire and their respective alligator clip connect to a different port on the CPX. The brown wire goes to the GND port, red goes to VOUT, and orange goes to A1, or A# depending on what your coding requires.

  • Brown to GND
  • Red to VOUT
  • Orange to A#

Then connect the battery to the CPX across from where it would be plugged into a computer.

Final Assembly

  • Feed any wires connecting the CPX to the servo and battery through the opening in the base.
  • snap the CPX into the snap-fit holder that is on top of the base.
  • Turn the battery on and glue two corners of the base lid down to the base
  • glue the horn connected to the carousel to the servo motor
  • Make sure the code is saved on CPX and start the Carousel
  • Have Fun!!