What you build
Two blasters that play a real game. Pull the trigger and your blaster flashes a coded packet of infrared light at the other player. Their blaster decodes it, checks it came from the other team, takes a health point off the bar and buzzes. Five hits is a tag-out, and the first team to three tag-outs wins.
Each blaster has:
- The brain: an Arduino Uno.
- The gun: an infrared LED behind a 220 ohm resistor on pin 3.
- The target: a VS1838B infrared receiver on pin 2.
- The controls: a trigger on pin 4 and a reload button on pin 6.
- The health bar: five WS2812 LEDs on pin 5, in the team color.
- Sound: an active buzzer on pin 7.
- The team: a jumper on A0. Left open it is RED, wired to ground it is BLUE.
Each blaster's LED is wired to the other blaster's receiver. That wire is the line of sight: it carries only light flashing at 38 kHz, as the air between two players does, and a shot never reaches the blaster that fired it.
How it works
A carrier. The receiver answers only infrared flashing at 38 kHz, so sunlight, lamps and warm bodies are ignored.
A coded packet. Each shot is an NEC frame, the code of most TV remotes: a 9 ms burst, a 4.5 ms gap, then 32 bits, the address 0x1A, the command, and an inverted copy of each so a garbled frame is thrown away.
Fields in a byte. The command's high four bits say what the packet is and the low four say which team sent it: 0x11 is a shot from RED, 0x12 a shot from BLUE, and 0x2t reports that team t was tagged out.
Health and timing. Five health, a half-second safe window after each hit, a three-second respawn, a six-shot clip and a reload of a second and a half, all timed with millis(), so the receiver is never ignored.
Sounds as rhythms. The active buzzer has one note, so each event has its own pattern of on and off times: a chirp to fire, a buzz when hit, a double click when empty, three beeps when reloaded and a long tone when out.
The course
Build a laser tag system gets there in six lessons, all on the same two blasters:
- IR shots: the 38 kHz carrier, an NEC frame and a hit.
- Team codes: a team in the command byte, a jumper to pick it, and no friendly fire.
- Hits and health: a WS2812 health bar, tag-outs and respawns.
- Reloads: a six-shot clip and a reload that leaves you open.
- Sound: a sound for every event.
- Project: a two-team game: tag-outs reported to the shooter and first to three wins.
Every step is checked against the running circuit, apart from the last, where you make the game your own and share it.