I love brain-teaser gadgets, so I wanted to make something that combines simple electronics with a game that keeps your math skills sharp. My idea was a small device that displays math questions on an LCD, lets you enter answers with a keypad, and gives feedback with lights and sound.
I searched around for keypad-LCD projects to get inspiration, and then modified the idea heavily: I added game modes, an RGB LED, and a buzzer for sound cues. The final result is a fun little quiz machine.
Used to design and simulate the complete circuit.
Used to export code to the Arduino hardware
Arduino UNO: Main controller to handle input, logic, and outputs.
16x2 I²C LCD:: Displays the math problems and messages.
4x3 Membrane Keypad: Used to type in answers, * as reset, # as submit.
Push Button (green): Toggles between game modes (Multiplication or Division).
RGB LED (Common Cathode): Output indicator (blue = input mode, green = correct, red = wrong).
Three 220 Ω resistors: Current limiting for each LED channel.
Piezo Buzzer: Sound feedback for correct/incorrect answers.
Mini Breadboard: For wiring components.
Jumper wires: To connect everything.
USB cable / power supply for Arduino: To power the system.
Cardboard: To build the structure body.
Cutter: To cut the cardboard into the needed shape.
Sellotape: To hold the body & components together.
(Follow along if you want to make the same circuit)
The boring part first... Hardware:
Add the parts: Arduino UNO, 16x2 I²C LCD, 4x3 keypad, RGB LED, 3×220Ω resistors, push button, piezo buzzer, and a breadboard.
Wire the LCD:
VCC → Arduino 5V
GND → Arduino GND
SDA → Arduino A4
SCL → Arduino A5
Wire the Keypad:
R1 → Arduino pin 9
R2 → Arduino pin 8
R3 → Arduino pin 7
R4 → Arduino pin 6
C1 → Arduino pin 5
C2 → Arduino pin 4
C3 → Arduino pin 3
Wire the RGB LED (common cathode):
COM → Arduino GND
R → Arduino pin 10 through 220Ω resistor
G → Arduino pin 11 through 220Ω resistor
B → Arduino pin 12 through 220Ω resistor
Wire the Push Button:
One leg → Arduino pin 13
Other leg → Arduino GND
Wire the Buzzer:
(+) → Arduino pin 2
(–) → Arduino GND
The fun part! Software:
The code will be in Arduino C, we want to implement several systems:
The Arduino randomly generates multiplication or division questions depending on the game mode.
User types digits via keypad, * clears the input, # submits the answer.
If the answer is correct:
RGB LED turns green, buzzer plays a short tone, and a new question is generated.
If the answer is wrong:
RGB LED turns red, buzzer plays an error tone, and the LCD prompts retry with a new question.
While typing input, RGB LED stays blue, to indicate accepting input.
Pressing the push button on pin 13 switches between Multiplication Mode and Division Mode. The LCD updates to show the current mode.
Working circuit demo, find the actual Wokwi project here
Now that we designed the circuit and the code, let's implement both, starting from the code;
Imported libraries:
Pins setup:
Dynamic variables:
Setup function:
Loop function: (Main logic containing Nested If && Logical Operators.)
Helper functions: (to make life easier and avoid duplication.)
I Mounted the Arduino UNO on the table as the main controller and placed a mini breadboard next to it for wiring.
I Placed the LCD module near the top edge of the breadboard. Since it’s I²C, I only needed four wires: I connected its VCC and GND to the breadboard rails, and then ran two jumper wires from SDA → A4 and SCL → A5 on the Arduino.
Fixed the 4x3 keypad to the workspace (With my beloved Sellotape.) and ran its 7 wires down to the Arduino digital pins 3-9.
Inserted the RGB LED into the breadboard so each leg had its own row. I added three 220 Ω resistors, one for each color leg (R, G, B), and connected them to pins 10, 11, and 12 with jumper wires. The common cathode leg went to the GND rail.
4.5. I then realized Inserting the RGB LED directly onto the breadboard was a bad idea... because now I can't display it outside, thus I extended it with jumper wires.
Added the push button directly onto the Arduino with jumper wires, connecting one side to Arduino pin 13 and the other side to GND.
Mounted the buzzer on the breadboard, placing its (+) pin to Arduino pin 2 and its (–) pin to the ground rail.
Once everything was wired, I went back and double-checked connections on the LED, buzzer, and LCD connections, making sure all GNDs were tied to the Arduino’s GND.
8. Finally, I connected the Arduino to my laptop via USB, uploaded the code, and powered it on. The LCD lit up immediately, the LED cycled through its states during testing, and the keypad input worked as expected.
9. Then I designed and cut a housing from cardboard, and place the components inside.
10. After securing it all, I tested the circuit one last time, and everything worked as expected.
One of my peers suggested that instead of having the player just enter the numbers directly, I could use the * and # keys on the keypad as “reset” and “submit” buttons. I really liked that idea because it made the game feel more complete and avoided accidental inputs. I built on their suggestion by also adding a push button to toggle between two game modes (multiplication and division).
The LCD initially gave me trouble, it wasn’t displaying any text, it would just light up blue but stay blank. I wasn’t sure if the problem was with the wiring or the code. After some searching, I learned that I²C LCD modules can use different addresses (commonly 0x27 or 0x3F). I had been using the wrong address in the code. I tested both options and once I set the address to match my module (0x27), the LCD immediately started showing the questions correctly.
Another challenge was getting the RGB LED colors right. The LED legs were very close together, and at first I mixed up the common cathode with the green pin, which caused the colors to behave unpredictably. After checking the datasheet and rewiring with resistors in the right order, the LED worked as intended.
Also, I highly suggest the usage of helper functions in your code. There’s a principle in programming called DRY (Don’t Repeat Yourself), if a part of your code is repeated often, it’s usually better to put it in a function and call it when needed instead of copy-pasting. This makes the code less confusing, easier to debug, and much more modular.
Learning how to code in Arduino C, How to use nested Ifs, Logical operators, And dynamics variables will certainly aid me into making my final project, as it is highly dependent on code quality and execution.