Arduino Uno · Final Project

The Number
Guessing Machine

A handheld guessing game built on an Arduino Uno. Pick a difficulty, punch in a guess on the keypad, and chase the hidden number while the 16×2 LCD teases you with “Too High” and “Too Low.” Dial in the screen with a potentiometer, and flip pages with the IR remote’s up & down buttons.

DDavid CChloe VVictor
Pick difficulty:
A:E B:M C:H D:N
CONTRAST · 62%
LIVE DEMO Drag the knob ↕
IR ▲▼
Tap ▲ ▼ to switch the screen page — just like the real remote.
01 — The Build

Six parts, one little machine.

Everything runs off a single Arduino Uno. Here’s what’s on the board and which pins it talks to.

12·11·5·4·3·2

16×2 LCD

The HD44780 display driven by LiquidCrystal. Shows prompts, your guess, and feedback.

V0 / analog

Potentiometer

Twists the LCD contrast pin so the characters stay crisp under any lighting.

13·10·9·8 / 7·6·A1·A0

4×4 Keypad

Scanned manually as a matrix — digits to guess, * to clear, # to submit.

A3

IR Receiver

Reads NEC codes from the remote. Only ▲ / ▼ are used — to page the display.

A2

Piezo Buzzer

Beeps for wrong guesses and plays a little victory jingle when you nail it.

USB · 5V

Arduino Uno

The brain. Holds the game logic, the keypad scanner and the IR decoder all at once.

A5

Random Seed

A floating analog pin feeds noise into randomSeed() so every game differs.

NEC

Two Pages

A Game page and an Info page. The remote flips between them — no extra wiring.

02 — Circuit Preview

The wiring, laid bare.

The full breadboard layout from our build. Click the image to open it full-size.

circuit-preview.png
Arduino number guessing game breadboard wiring: Uno, 4x4 keypad, 16x2 LCD, potentiometer, piezo buzzer and IR remote. ⤢ click to zoom

Arduino Uno

Powered over USB · the controller

4×4 Keypad

8 lines into D13–D8 & D7/D6/A1/A0

16×2 LCD

RS 12 · E 11 · D4–D7 → 5/4/3/2

Potentiometer

Wiper → LCD V0 contrast pin

Piezo Buzzer

Signal on A2 · sound feedback

IR Receiver + Remote

Signal on A3 · ▲▼ navigation

03 — How To Play

Guess the number. Beat the beep.

Four quick beats from boot to bragging rights.

STEP 1

Pick a difficulty

Press A, B, C or D to set the range. The LCD confirms it.

STEP 2

Type your guess

Use the keypad digits. Hit * to clear a mistake before you commit.

STEP 3

Submit with #

The board says Too High, Too Low, or Correct! — and buzzes to match.

STEP 4

Peek the Info page

Press the remote’s to see the current max, to jump back to the game.

Difficulty levels

A

Easy

1 – 10
B

Medium

1 – 100
C

Hard

1 – 1,000
D

Nightmare

1 – 10,000

…and two secret modes

Every new round rolls the dice. Rarely, the machine drags you somewhere far worse.

??? Impossible

1 – 100000

An ominous three-note sting plays, the screen flashes a warning, and the range explodes to one hundred thousand.

ROLL CHANCE — 8% per new round
The Backrooms

1 – 10000000

A long, dread-soaked drone announces it. Ten million possibilities. Good luck finding the way out.

ROLL CHANCE — 5% per new round
04 — The Code

The full sketch.

Written for the Arduino IDE. Manual keypad scanning and a modern IRremote.hpp decoder keep it stable in simulation and on real hardware.

C++ final_project1.ino
Full syntax-highlighted Arduino source for the Guess Number Game. ⤢ scroll to read · click to enlarge
05 — Functions

What each piece does.

The sketch is split into small, single-purpose functions. Here’s the tour.

chargetCustomKeypad()

Scans the 4×4 keypad by hand — driving each row low and reading the columns with internal pull-ups. Replaces Keypad.h entirely to avoid library crashes in simulation. Returns the pressed key, or 0.

matrix scandebounceno library
chargetIRKey()

Decodes NEC remote signals and maps each command to a key. The up arrow becomes 'U' and the down arrow 'X' — the only two buttons the game actually listens to.

IR · NEC▲ = U▼ = X
voidupdateDisplay()

Redraws the LCD for whatever page you’re on — the difficulty menu, the live guessing screen with your input buffer, or the Info page showing the current max.

page 0 · gamepage 1 · info
voidchooseDifficulty()

A blocking loop at boot that waits for A/B/C/D, sets the number range, and flashes a quick “Range Set” confirmation before the first round begins.

startupA·B·C·D
voidstartNewGame()

Rolls for the secret modes, sets the active maximum, picks a fresh random target, clears your input and resets to the game page.

random targetsecret roll
voidloop()

The heartbeat: read a key (keypad first, then IR), handle page navigation, append digits, clear on *, and judge the guess on # with the right sound and message.

inputjudgingnavigation
voidplaySuccessMusic()

A bright ascending arpeggio on the piezo buzzer — the reward for a correct guess before the next round spins up.

piezo · A2victory
voidplaySecretIntro() · playBackroomIntro()

The dramatic stingers that announce the Impossible and Backrooms modes — short tone sequences paired with a flashing on-screen warning.

tone()ambience
06 — The Team

dcv = David · Chloe · Victor

Three people, one breadboard, far too many “Too High” beeps.

D

David

CIRCUIT & BUILD
C

Chloe

FIRMWARE & LOGIC
V

Victor

SOUND & TESTING