Random laser pointer station. Embedded Rust
- Laser moves randomly.
- Configurable
xandyarea of laser movement. - Manual laser control from a phone over WiFi.
- Simple USB-C connector for power and programming.
- 1 x ESP32 C3 SuperMini
- 1 x 3.3V Laser diode
- 2 x SG90 servo motor to position the laser
- 2 x 10kΩ potentiometer to control the servo X and Y range
- 1 x Latching button to preview the laser area
- 1 x Toggle switch to control power
- 1 x USB-C Female connector for power and programming
- 1 x 3D printed case
The latching preview button doubles as a boot-time mode switch. The firmware reads it once at startup:
- Unlatched at boot: random mode. The laser walks randomly inside the bounding box set by the two potentiometers, and latching the button previews the box corners. After 10 minutes of runtime the unit deep sleeps for 20 minutes, then wakes and repeats.
- Latched at boot: manual mode. The firmware starts a WiFi access point and serves a web D-pad, described below. The potentiometers and the button are ignored, and the unit never deep sleeps.
To switch modes, set the button and power cycle.
Booting with the preview button latched starts an open WiFi access point with a DHCP server and serves a web D-pad for driving the laser by hand across the full servo range.
- Join the
laser-dpadWiFi network and keep the connection when the phone warns about no internet. - Open http://192.168.2.1/ (plain
http, browsers that forcehttpswill hang). - Hold a direction button to glide the laser. The center tile shows the round-trip time of each command.
- The page keeps one persistent HTTP connection so commands avoid a TCP handshake, and a held button re-sends its direction every 120 ms as a keepalive.
- The firmware stops all movement if no command arrives for 350 ms, so a lost release packet cannot leave a servo running away.
RAMP_COUNTS_PER_SECinsrc/manual/mod.rssets the glide speed.
This project is built in a no_std environment utilizing the esp-hal crate.
The ESP32-C3 is RISC-V, so the stock stable toolchain works. rust-toolchain.toml pins the channel and installs the riscv32imc-unknown-none-elf target and rust-src on first build, so the only setup is:
cargo install espflashBuild, flash, and stream serial logs until Ctrl-C (the runner is configured in .cargo/config.toml):
cargo run --release- Add 'programmer' support for an external module with a little screen and joystick that can be plugged into the main station to program key settings:
- Speed
- Bounding box
- Design ergonomic enclosure for programmer
- Upgrade to bigger, more robust, servos
- Redesign main enclosure with wall mounting keyholes
- Take final product image
