CPX INSPIRED TIMER (REVAMPED AND HOLIDAY EDITION)

by pjorge2 in Design > 3D Design

12 Views, 0 Favorites, 0 Comments

CPX INSPIRED TIMER (REVAMPED AND HOLIDAY EDITION)

IMG_1788.jpg
IMG_1789.jpg

Our team has decided to improve our CPX inspired timer, just in time for the holidays! We have made it green and red to represent the holiday season, and included a more diverse and intricate coding system via python, and cleaned up the physical design so the wires aren't as messy. It still has just enough bulk for it to be impossible to lose, and it is convenient enough to use under any situation deemed necessary to time!

Supplies

IMG_1635.jpg
  1. CPX
  2. Servo Motor (NOTE PLEASE DO NOT USE CONTINUOUS SERVO MOTOR)
  3. Appropriate Materials For 3D Printing
  4. Alligator Clip Wiring
  5. Battery Pack
  6. Micro USB cable (or any cable that works with your CPX and PC)


https://www.adafruit.com/product/3000 (CPX PURCHASE)

https://www.adafruit.com/product/727 (BATTERY PACK PURCHASE)

https://www.adafruit.com/product/1008 (ALLIGATOR CLIP PURCHASE)

https://www.adafruit.com/product/592 (CABLE PLUG IN PURCHASE, YOU MAY USE ANY CABLE THAT CAN PLUG INTO THE CPX AND YOUR OWN PC)

https://www.adafruit.com/product/169 (SERVO MOTOR PURCHASE)

https://www.makerbot.com/3d-printers/sketch-large/ (3D PRINTER PURCHASE)

https://www.bhphotovideo.com/c/product/1910973-REG/flashforge_ffpla1175n_pla_1_75mm_1kg_natural.html?ap=y&smp=Y (FILAMENT PURCHASE)

3D PRINTS!

Screenshot 2025-11-17 at 11.48.56 AM.png
Screenshot 2025-11-17 at 11.49.25 AM.png
Screenshot 2025-11-17 at 11.49.54 AM.png

To get the process started, you first need to download the 3D models into Tinkercad. From Tinkercad, you may export these models into MakerBot. To do this, you need to

  1. Click export on the top right of the screen
  2. Click 3D print
  3. Click MakerBot
  4. Click "Continue To MakerBot"
  5. Sign in
  6. On the top middle of the screen, click on the button that says "Method X," and switch it to "Sketch"
  7. Click print preview on the top right of the screen
  8. Click export (with a usb drive already inserted into your computer)
  9. Drag newly downloaded file into the usb drive
  10. Eject usb drive
  11. Print away at your 3D printer!


NOTES:

YOU DO NOT NEED SUPPORTS FOR THIS PRINT!!!!!!!!!!

YOU MAY USE ANY COLORS YOU WISH FOR THIS PRINT, BUT WE DECIDED TO GO FESTIVE WITH RED AND GREEN!!!!!!!!!!

IF THE PRINTING EXCEEDS 4 HOURS (OR LONGER THAN YOUR DESIRED TIME), YOU MAY PRINT THE BOX AND THE CPX CASING SEPARATELY!!!!!!!!!!


https://www.tinkercad.com/things/kzIPL1vt8Ve-swanky-bojo-fulffy

Coding

Before we construct our new timer, we will write a quick and easy code to allow our timer to function!


EXPLANATION OF THE CODE:

This program runs on the Adafruit Circuit Playground Express and creates a countdown timer that uses lights, sound, and a servo motor to show the passage of time.

At the beginning, the code imports the necessary libraries for timing, controlling a servo motor, and accessing the built-in features of the Circuit Playground Express such as buttons, LEDs, and the speaker. A few configuration settings define how long the timer should run, what tone to play when it finishes, and which pin the servo is connected to. The servo is then initialized using a PWM signal on the board’s dedicated servo pin.

Two helper functions are defined. The first, beep(), plays a short tone through the speaker a specified number of times. The second, show_progress(), updates the NeoPixel LEDs to display how much time remains in the countdown. It does this by lighting up a number of green LEDs proportional to the remaining time.

Once everything is set up, the program waits for the user to press button A. When button A is pressed, the timer begins. The program calculates the end time and enters a loop that runs until the countdown finishes. During each cycle of this loop, it updates the NeoPixels to reflect the time left and moves the servo once per second. The servo alternates between 0 degrees and 90 degrees, switching angle each new second to give a clear visual and mechanical indication that time is passing.

A short delay ensures the loop runs efficiently without overwhelming the board.

When the timer reaches zero, all the NeoPixels turn red, a “Time’s up!” message is printed, and the program plays three beeps to signal that the countdown has finished. Button B can be pressed at any time to clear all LEDs and return the board to a neutral state.

Overall, the program provides a simple but effective countdown system where lights, sound, and a moving servo motor work together to make the timer easy to see, hear, and feel.





You may copy and paste this code into your python coding language platform.





import time

import pwmio

from adafruit_motor import servo

from adafruit_circuitplayground import cp


# === CONFIGURATION ===

TIMER_SECONDS = 10 # Change this to set countdown duration

BEEP_FREQUENCY = 880 # Hz

BEEP_DURATION = 0.2 # seconds

SERVO_PIN = cp.SERVO_PIN # A1 on Circuit Playground Express


# === SERVO SETUP ===

pwm = pwmio.PWMOut(SERVO_PIN, frequency=50)

my_servo = servo.Servo(pwm)


# === HELPER FUNCTIONS ===

def beep(times=1):

"""Play a short tone on the CPX speaker."""

for _ in range(times):

cp.play_tone(BEEP_FREQUENCY, BEEP_DURATION)

time.sleep(0.1)


def show_progress(seconds_left, total_seconds):

"""Light NeoPixels to show remaining time."""

pixels_to_light = int((seconds_left / total_seconds) * 10)

cp.pixels.fill((0, 0, 0)) # Clear

for i in range(pixels_to_light):

cp.pixels[i] = (0, 50, 0) # Green

cp.pixels.show()


# === MAIN LOOP ===

print("Press button A to start timer.")


while True:

if cp.button_a: # Start timer when button A is pressed

print("Timer started!")

start_time = time.monotonic()

end_time = start_time + TIMER_SECONDS

last_servo_step = -1 # Track last whole-second tick


while time.monotonic() < end_time:

now = time.monotonic()

seconds_left = int(end_time - now)

show_progress(seconds_left, TIMER_SECONDS)


# === SERVO ROTATION EVERY 1 SECOND ===

seconds_elapsed = int(now - start_time)

if seconds_elapsed != last_servo_step:

last_servo_step = seconds_elapsed


# Alternate between 0° and 90°

angle = 90 if (seconds_elapsed % 2 == 0) else 0

my_servo.angle = angle


time.sleep(0.1)


# Timer finished

cp.pixels.fill((50, 0, 0)) # Red

cp.pixels.show()

print("Time's up!")

beep(3)


# Optional: Button B to reset pixels

if cp.button_b:

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

cp.pixels.show()



https://learn.adafruit.com/welcome-to-circuitpython/what-is-circuitpython?gad_source=1&gad_campaignid=21079267614&gbraid=0AAAAADx9JvRCHOJUdaLnozKHF7NmwWEDi&gclid=Cj0KCQiArOvIBhDLARIsAPwJXObDN76cFwsf9N90qrjJLLDEfLNSVvqmhwD7rQ10prK-q4Qo1ARmOZAaAvABEALw_wcB

Properly Wiring the Servo Motor, and Connecting It to the CPX

IMG_1637.jpg
IMG_1639.jpg

The first step of physical construction is to wire the servo motor, and to place your CPX into the red printed casing


  1. Take your servo motor
  2. Take alligator clips
  3. Plug in alligator clips into the servo motor
  4. Clip the alligator clips onto the CPX


NOTES:

IT DOES MATTER WHERE YOU CLIP THE WIRES ONTO THE CPX!!!!!!!!!! ( "VOUT," "A1," "GND")

VOUT = POWER

A1 = LIGHTS/SOUNDS

GND = GROUND



Plugging Battery Pack Into the CPX

IMG_1641.jpg

The next step is just to simply plug in another material into the CPX!


  1. Take your battery pack and plug the white part at the end of the wires into the black outlet on the CPX.

Putting Everything Together!

IMG_1642.jpg
IMG_1643.jpg
IMG_1646.jpg

This next step involves using the (2) 3D prints earlier in these instructions!


  1. Take your hollowed out box that you 3D printed
  2. Put the battery pack flat on the ground and put it on the far left side (or right side) of the box (look at image above)
  3. Place servo motor next to the black battery pack inside the box (look at image above)
  4. Place CPX inside of the red casing
  5. Center the red casing on top of the green box



NOTES:

  1. SERVO MOTOR WILL BE ON AN ANGLE, AND THAT IS FINE!!!!!!!!!!
  2. YOU MAY HOT GLUE (OR USE ANY SUBSTANCE THAT WILL MAKE THE PIECES STAY IN PLACE) PIECES THAT ARE LOOSE

THE FINAL PRODUCT!!!!!!!!!!

IMG_1648-3.jpg
IMG_1649-2.jpg
IMG_1650-2.jpg
IMG_1651-2.jpg

It is really as simple as that! After that easy process, you now have a reliable and unique timer to fulfill all of your timing needs, ranging from board games to sporting events!


NOTES

  1. Hot gluing materials is recommended because it will make the design more compact and look cleaner. For the purposes of this assignment, we decided not to hot glue the design so it could be easily deconstructed.