Maze Game
Nov 2023
GOAL: create a motorized game
SKILLS: CAD (OnShape), laser cutting, 3D printing, electrical wiring, CircuitPython programming, soldering, PCB design (kiCAD), PWM motor control, use of microcontrollers (feather RP2040)
In this game, the user uses the left white button to rotate the maze counter-clockwise and the red right button to rotate the maze clockwise.
This maze game is controlled by an H-bridge motor controller, a feather RP2040, and circuit python.

CircuitPython Code
import board
import digitalio
import time
import pwmio
button1 = digitalio.DigitalInOut(board.D10)
button1.direction = digitalio.Direction.INPUT
button1.pull = digitalio.Pull.UP #Use pull-up resistor
button2 = digitalio.DigitalInOut(board.D11)
button2.direction = digitalio.Direction.INPUT
button2.pull = digitalio.Pull.UP # Use pull-up resistor
diagonal1 = pwmio.PWMOut(board.D12, frequency=500, duty_cycle=0) #Set PWM frequency and initial duty cycle
diagonal2 = pwmio.PWMOut(board.D13, frequency=500, duty_cycle=0) #Set PWM frequency and initial duty cycle
while True:
if not button1.value and button2.value:
diagonal1.duty_cycle = 32000 # 50% duty cycle, adjust as needed
diagonal2.duty_cycle = 0
time.sleep(0.05)
elif not button2.value and button1.value:
diagonal1.duty_cycle = 0
diagonal2.duty_cycle = 32000 # 50% duty cycle, adjust as needed
time.sleep(0.05)
else:
diagonal1.duty_cycle = 0
diagonal2.duty_cycle = 0
time.sleep(0.05)