The Numbers Game
The fluorescent lights flicker overhead as you adjust the salvaged rotary encoder, its metal shaft catching the harsh glow of the emergency lighting. Another sleepless night in Sector 7, another puzzle to solve. The survivors have been asking for entertainment, something to keep their minds sharp during the endless hours of waiting.
Your fingers trace the weathered components spread across the workbench. A seven-segment display glows amber in the dim light, numbers cycling as you test the connections. The rotary encoder clicks with satisfying precision, each detent a small victory against the chaos outside. A buzzer sits silent, waiting to announce triumph or defeat.
You're building more than just a guessing game. You're crafting hope. Every component tells a story of human ingenuity, of minds that refuse to surrender to circumstance. The HERO Board hums quietly, processing each turn of the encoder, each press of the button. It doesn't know it's helping rebuild civilization one game at a time.
Outside, the wind howls through the skeletal remains of the old world. Inside, you're creating something new. A magic number guesser that will soon echo with the laughter of survivors, the groans of near misses, the cheers of perfect guesses. The components don't care about the apocalypse. They just want to work, to serve, to bring a moment of joy to a world that desperately needs it.
What You'll Master
When you complete this project, you'll command a sophisticated guessing game that combines user input, random number generation, and immediate feedback. You'll master the art of reading rotary encoder rotation, debouncing button presses, and creating dynamic seven-segment display output.
More importantly, you'll understand how to architect interactive systems that respond intelligently to user actions. This isn't just about making numbers appear on a display. You're building the foundation for any device that needs to read user input, make decisions, and provide meaningful feedback.
You'll walk away knowing how to integrate multiple input sources, implement game logic with state management, and create engaging user experiences through sound and visual feedback. These skills transfer directly to building control panels, interactive displays, and any project where humans need to communicate with machines.
Understanding Interactive Games
Think about the last time you played a guessing game with friends. Someone thinks of a number, you make a guess, they tell you if you're right or wrong. Simple, but engaging. Now imagine that friend is a machine, and instead of speaking, it communicates through lights, sounds, and displays.
That's exactly what we're building. The rotary encoder becomes your voice, letting you "speak" numbers by turning a knob. The seven-segment display becomes the machine's face, showing your current guess. The button becomes a handshake, the moment you commit to your choice. And the buzzer becomes the machine's emotional response, celebrating your victories or commiserating your defeats.
But here's where it gets interesting. Unlike a human friend, our machine friend can generate truly random numbers. It doesn't have patterns, preferences, or tells. Every game is genuinely unpredictable, which makes winning feel earned rather than lucky. The microcontroller becomes an impartial judge, incapable of favoritism or bias.
This project teaches you the fundamental architecture of interactive systems. Input devices collect user intentions, processing units make decisions based on those inputs, and output devices communicate results back to the user. Master this pattern, and you've unlocked the secret to building everything from game controllers to industrial control panels.
Wiring the Number Guesser

- Connect the seven-segment display's segment pins (A-G, DP) to digital pins 2-8 and 10. Each segment needs its own data line because we're directly controlling which segments light up.
- Wire the rotary encoder's CLK pin to digital pin 11, DT pin to pin 10. These carry the quadrature signals that tell us rotation direction and speed.
- Connect the encoder's SW (switch) pin to digital pin 9 with INPUT_PULLUP enabled. This gives us a clean button press signal without external resistors.
- Attach the buzzer's positive lead to digital pin 12, negative to ground. This creates our audio feedback channel for game results.
- Ensure all ground connections are solid. Poor grounds cause erratic behavior, especially with the sensitive encoder signals.
Complete Code
Here's the complete magic number guesser code. Copy this into your HERO Board IDE, then we'll break down how it works: