A Budget lightgun using esp32
Patent-safe lightgun controller using physical bezel detection via ESP32-S3 + OV2640 camera.
No software borders, no calibration, no infringement of patents at the time of comit
Perfect for Point Blank 2, House of the Dead, and any MAME/DuckStation lightgun game at 1080p/60 FPS.
| Part | Model / Spec | AliExpress Link | Price (GBP) |
|---|---|---|---|
| ESP32-S3 CAM Board | LilyGO T-SIMCAM (OV2640, N16R8, USB-C) | ||
| Microswitch (Trigger) | ZIPPY VM-P1L (3-pin, 50g, 4.8mm terminals) | ||
| Recoil Solenoid | 5V Push-Pull Mini (8x10mm, 4mm stroke) | ||
| MOSFET Driver | IRF520 Module (for solenoid control) | ||
| Wide-Angle Lens | M12 120° (crop to ~85° effective) | ||
| Jumper Wires | Dupont 120pcs (10–20cm) | ||
| 3D-Print Filament | PLA (~50g,) |
Total Estimated Cost: £28–£35
- Bezel Detection: Finds physical monitor frame using OpenCV-style edge detection.
- No Calibration: Plug-and-play on any TV/monitor.
- USB/BLE HID Mouse Output: Works with MAME, DuckStation, RetroArch.
- Recoil Feedback: 50ms solenoid pulse on trigger.
- 20–30 FPS at QVGA (320x240) — smooth for lightgun games.
- Patent-Safe: Avoids rendered content, borders, polarization, perspective math.
# Arduino IDE Setup
1. Install ESP32 Board Package
2. Add Libraries:
- `BleMouse` by T-vK
- `esp32-camera` (built-in)
3. Select Board: "ESP32S3 Dev Module"
4. Upload sketch from `/firmware/`
Key Code Snippetscpp
// camera_config_t
config.pixel_format = PIXFORMAT_GRAYSCALE;
config.frame_size = FRAMESIZE_QVGA;
config.fb_count = 3; // Triple buffer for stability
cpp
// Recoil on trigger
if (digitalRead(BUTTON_PIN) == LOW) {
bleMouse.click(MOUSE_LEFT);
digitalWrite(SOLENOID_PIN, HIGH);
delay(50);
digitalWrite(SOLENOID_PIN, LOW);
}
cpp
// Crop 120° lens to ~85° effective FOV
int crop_w = fb->width * 0.8;
int crop_h = fb->height * 0.8;
int start_x = (fb->width - crop_w) / 2;
int start_y = (fb->height - crop_h) / 2;
3D ModelGun Shell: Cults3D Lightgun STL (Free)
Print: PLA, 0.2mm layer, 20% infill, red filament
Mount: Camera at muzzle, ESP32 inside, solenoid at rear
Wiring
ESP32-S3 GPIO:
├── GPIO1 → Microswitch NO
├── GND → Microswitch COM
├── GPIO2 → MOSFET IN (solenoid control)
├── 5V → Solenoid (+)
├── GND → Solenoid (–) + MOSFET GND
Use flyback diode across solenoid terminals.
Setup & TestingFlash firmware
Pair via Bluetooth or use USB HID
Run MAME/DuckStation in borderless fullscreen
Point at bezel — cursor follows center reticle
Pull trigger — shoots + recoil kick
Games TestedGame
Emulator
Notes
Point Blank 2
MAME / DuckStation
Perfect headshot tracking
House of the Dead
Model 2 / Demul
Smooth 60 FPS, recoil feels great
LicenseMIT License — Free to use, modify, and distribute.