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)
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
- CPX
- Servo Motor (NOTE PLEASE DO NOT USE CONTINUOUS SERVO MOTOR)
- Appropriate Materials For 3D Printing
- Alligator Clip Wiring
- Battery Pack
- 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!
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
- Click export on the top right of the screen
- Click 3D print
- Click MakerBot
- Click "Continue To MakerBot"
- Sign in
- On the top middle of the screen, click on the button that says "Method X," and switch it to "Sketch"
- Click print preview on the top right of the screen
- Click export (with a usb drive already inserted into your computer)
- Drag newly downloaded file into the usb drive
- Eject usb drive
- 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
The first step of physical construction is to wire the servo motor, and to place your CPX into the red printed casing
- Take your servo motor
- Take alligator clips
- Plug in alligator clips into the servo motor
- 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
The next step is just to simply plug in another material into the CPX!
- 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!
This next step involves using the (2) 3D prints earlier in these instructions!
- Take your hollowed out box that you 3D printed
- 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)
- Place servo motor next to the black battery pack inside the box (look at image above)
- Place CPX inside of the red casing
- Center the red casing on top of the green box
NOTES:
- SERVO MOTOR WILL BE ON AN ANGLE, AND THAT IS FINE!!!!!!!!!!
- YOU MAY HOT GLUE (OR USE ANY SUBSTANCE THAT WILL MAKE THE PIECES STAY IN PLACE) PIECES THAT ARE LOOSE
THE FINAL PRODUCT!!!!!!!!!!
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
- 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.