What you build
One booth, three games. The same three light gates are the pegs of a ring toss and the holes of a skee-ball lane, the way a real booth reuses its sensors, and the finished booth runs itself from attract mode to the last ticket.
- Three touch targets: TTP223 touch pads on pins 4, 3 and 2. Target 1 is also START.
- Three light gates: slotted photo interrupters on pins 7, 6 and 5. Click the card beside a gate to push something into its beam.
- The scoreboard: an eight-digit MAX7219 display on 12 (DIN), 11 (CLK) and 10 (CS).
- Sound: an active buzzer on pin 9.
- The brain: an Arduino Uno.
How it works
Touch is capacitance. A TTP223 feels the tiny change a finger makes near its pad, even through thin plastic, and drives SIG HIGH. Like the real chip, it takes about 60 ms to answer and ignores the pad for half a second after power-up.
Blocked is HIGH. Each light gate shines infrared across a slot. Anything in the slot cuts the beam and the pull-up takes S HIGH.
Edges catch fast balls. A skee-ball ball cuts a beam for a few milliseconds. The loop never waits, so it sees the moment each beam is cut.
Dwell time tells a ringer from a bounce. A ring counts only once its peg's beam has stayed cut for 300 ms. A ring that clips the peg and bounces away cuts it for less.
A high score that survives the night. The best score lives in the Uno's EEPROM, read at power-up and written only when it is beaten, because each cell wears out after about 100,000 writes. An erased chip reads 0xFFFF, which means no high score yet.
Tickets are a table. One ticket for every 30 points in whole-number division, and a jackpot of 20 more at 400 or over. The machine counts them out one chirp every 150 ms.
The course
Build carnival games gets there in six lessons, all on the same wiring with a new sketch each time:
- Whack targets: touch sensors, random pops, hits, misses and a time limit.
- Ring toss sensors: a gate at each peg, ringers, bounces and a turn.
- Skee-ball lanes: holes worth 10, 30 and 50, fast balls and the scoreboard.
- Scores: a high score kept in EEPROM.
- Tickets: a ticket table, a jackpot and a ticket machine.
- Project: a game booth: attract mode, a 30 second clock and the whole booth.
Every step is checked against the running circuit, apart from the last, where you make the booth your own and share it.