Skip to main content
Version: ACS CC

LaserChase

A smart cat laser toy with manual or automatic movement patterns.

info

Author: Ghiță Alexandru
GitHub Project Link: GitHub

Description

LaserChase is a smart, interactive laser toy for cats, powered by a Raspberry Pi Pico 2W. The laser is mounted on two servo motors that allow it to move across two axes. It can operate in automatic mode - following 4 pre-programmed motion patterns (horizontal line, vertical line, rectangle or circle) plus a random pattern, or in manual mode - controlled by the joystick. Mode and pattern switching is done via async button presses, making the experience more dynamic and engaging. The goal is to mimic the unpredictable movement of real prey, keeping your cat entertained and active.

Motivation

I wanted to create something practical and enjoyable for my personal use at home. As a cat owner, I thought this project would be a perfect blend of utility and fun-bringing joy to my pet while allowing me to experiment with hardware and software in an engaging way. Building LaserChase has given me the opportunity to explore electronics, real-time control, and embedded programming, all while making my cat happy.

Architecture

Architecture

The main software components of the project include:

  • Control Module: Handles manual input from a joystick (ADC) and async button presses (GPIO) to switch modes and patterns while keeping the laser in motion.
  • Mode Manager: Keeps track of the current operating mode and pattern count and interprets input accordingly.
  • Movement Generator: Generates movement signals, from one of the 5 different patterns (automatic mode) or transformed from joystick input (manual mode).
  • Servo Driver: Sends PWM signals to the two servo motors inside the 2-axis 3D printed stand to move the laser pointer mounted on top of it.

These components interact as follows:

  • Input (buttons/joystick) -> Control Module -> Mode Manager -> Movement Generator -> Servo Driver -> Laser

Modes and Patterns

Switching between modes and patterns is done via two GPIO buttons:

ModeDescription
ManualJoystick controls the laser
Auto Pattern 0Horizontal sweep
Auto Pattern 1Vertical sweep
Auto Pattern 2Rectangle tracing
Auto Pattern 3Circular path (uses sin/cos)
Auto Pattern 4Random hops (using self implemented rand32)

Log

Week 5 - 11 May

Found out what how to connect and get input from buttons and joystick and how to power the laser and move the servo motors using the labs as example. Got the rest of the needed components and a second Raspberry Pi Pico 2W as a debug probe for easier programming of the main controller.

Week 12 - 18 May

Completed the schematic with a better understanding of how it should look like. Connected all of the harware components together and made sure they work. Added a picture of the hardware in its current form. Played around with the code to start things up for the software part.

Week 19 - 25 May

Finished setting up all of the needed hardware and started implemented the software. After correctly connecting the joystick to the servos and getting async input from the buttons, I started testing different options for the patterns. The final patterns that remain implemented are: horizontal line, verical line, rectangular motion, circular motion and my personal favorite, (pseudo-)random motion. Started building the final "product" to make the project good-looking for the PM fair presentation.

Hardware

  • Raspberry Pi Pico 2W: LaserChase uses a Raspberry Pi Pico 2W as the main controller.
  • SG90 Servo (x2) + Laser Pointer: Two SG90 servos are used to move the laser pointer on two axes.
  • Joystick Shield: Control is done via a joystick shield and mode and pattern switching through push buttons.
  • 9V Battery + Holder + DC-DC Step Down Module: Power is supplied through a 9V battery regulated by a step-down module to 5V.
  • Breadboard + Wires: Components are connected using wires and a breadboard.

Hardware progress

Hardware_1

Hardware_final

Schematics

KiCad

Bill of Materials

DeviceUsagePrice
2x Raspberry Pi Pico 2WMain microcontroller + debug probe80 RON
2x SG90 Servo MotorsControl the X/Y axes of the laser24 RON
Joystick Shield V1.AManual control of laser via joystick + buttons20 RON
DC-DC Step Down ModuleVoltage regulation from 9V to 5V13 RON
9V Battery + HolderPower source10.3 RON
2x BreadboardCircuit connection9 RON
WiresConnections between components8 RON
Micro USB CablePower and programming cable4 RON
2x Header PinsConnection to breadboard4 RON
Laser PointerRed colored laser2.6 RON
TOTAL---174.9 RON

Software

  • Main task updates PWM every 25 ms based on current mode
  • Each pattern is implemented as a separate function (except auto-sweep which incorporates 2 patterns):
    • auto_sweep() - moves in a horizontal or vertical line based on tick
    • rectangle() - moves in a rectangle shape using phases
    • pattern_circle() – moves in a circle using trigonometry
    • pattern_random() – jumps to random valid positions
  • Buttons are handled in separate async tasks with debouncing
  • Shared state is safely updated using AtomicU8
LibraryDescriptionUsage
embassyAsync HAL & runtimeCore framework enabling async embedded development
embassy-executorAsync task executorRuns async tasks concurrently on the microcontroller
embassy-rpRaspberry Pi Pico HALProvides peripheral access (ADC, GPIO, PWM, etc.)
defmtLogging & debug outputEfficient logging for embedded targets
defmt-rttRTT backend for defmtTransfers logs from the device over RTT (Real-Time Transfer)
embassy-timeAsync timers and delaysEnables non-blocking timers with Timer::after() and Duration
libmLightweight math libraryUsed for sinf and cosf in pattern generation
fixedFixed-point math utilitiesProvides traits for numeric conversions (ToFixed)
panic-probePanic handler for embeddedMinimal panic handler used for debugging
core::sync::atomicAtomic operationsThread-safe state sharing between async tasks
  1. Similar project
  2. Controlling SG90 with PWM in Rust
  3. SG90 2-axis 3D print design