PI-56BeginnerPremium

Raspberry Pi Pico Nim Game: Can You Beat the Pico? (10 LEDs + 4 Buttons + Buzzer)

Whoever takes the last stick loses: can you beat the Pico? The matchstick game Nim lights up with a Raspberry Pi Pico. 10 yellow LEDs are 10 sticks; you take turns removing 1, 2 or 3, 4 buttons pick your move and a buzzer voices every turn. The Pico uses a mod 4 trick to always leave you 1, 5 or 9 sticks: if you start, the right first move wins, but if the Pico starts it never loses.

0.0(0)
Raspberry Pi Pico Nim Game: Can You Beat the Pico? (10 LEDs + 4 Buttons + Buzzer)
Play the classic matchstick game with lights: 10 yellow lights are 10 sticks, you and the Pico take turns removing 1, 2 or 3, and whoever takes the last stick loses. The Pico knows a little maths trick and always tries to leave you 1, 5 or 9 sticks. Find the right first move and you can beat it; when the Pico goes first it never loses, and hint lights show the way if you get stuck.

Source Code

Premium Content

The source code, block version and FAQ of this project are open to Premium members.

  • All Project Code
  • Block version
  • Frequently Asked Questions