Interactive STM32 Quiz with Red/Green LED Feedback & BuzzerWHAT WE BUILT
We built NeoQuiz as a small, tactile way to turn a serial terminal into a hardware quiz buzzer. I wanted something simple that could run on an STM32 board, show questions on a 16x2 I2C LCD, accept answers over UART, and immediately tell the user whether they were right or wrong using only a buzzer and two LEDs. The result is a compact, reliable demo that’s great for classroom demos, maker nights, or just practicing embedded development with HAL/CubeMX.
Quick Summary
- An STM32-based quiz device that:
- Displays a question on an I2C LCD
- Accepts typed answers over UART (serial terminal)
- Lights a green LED and plays a positive tone for correct answers
- Lights a red LED and plays a negative tone for wrong answers
Components Used
- STM32 development board (STM32F407)
- 16x2 I2C character LCD (with PCF8574 I2C backpack)
- Wires, USB cable
Key features
- UART text input for user answers (serial console)
- I2C LCD display for questions and feedback
- Red and green LEDs for visual feedback (green = correct, red = wrong)
- Passive buzzer (PB0) for audible correct/wrong tones
- Simple STM32 HAL/CubeMX code and a small ws2812b-free driver
- Easy to expand: add more questions, non-blocking sounds, or additional indicators
Wiring
I2C -> STM32
- LCD I2C SDA -> PB7 (I2C1 SDA)
- LCD I2C SCL -> PB6 (I2C1 SCL)
- GND -> GND
- VCC -> 5V
CubeMX (.ioc) settings (how I set it up)
1. MCU: choose your STM32 part (STM32F407)
2. Clock: set system clock to appropriate frequency for your board (default HSI works for this demo).
3. Peripherals:
- I2C1: Enabled, pins PB6 (SCL) / PB7 (SDA) — leave default Timing for 100 kHz or set as required.
- USART1: Enabled, Asynchronous, 9600 baud, pins PA9 (TX) / PA10 (RX).
- GPIO: Configure three pins as GPIO_Output:
- PB0 — Buzzer
- PB10 — Green LED
- PB2 — Red LED
- Set GPIO Pull = NoPull, Speed = VeryHigh (optional).
4. Generate code and open the project in STM32CubeIDE.
How it works
- The MCU displays a question string on the I2C LCD.
- The user types the answer on a serial terminal (9600 baud) and presses Enter.
- The MCU reads the input (blocking read for simplicity), compares it case-insensitively to the stored correct answer, and:
- If correct: lights the green LED and plays a positive buzzer pattern.
- If wrong: lights the red LED and plays a negative buzzer pattern.
- After a short delay the LEDs turn off and the loop repeats.
Source Codes ( Insert all the source code into your src or inc file)
https://github.com/MichelleannArtiaga/-Interactive-STM32-Quiz-with-LED-Audio-Feed/tree/mainBuild & flash
1. After adding the code and configuring pins in CubeMX, generate the project and open it in STM32CubeIDE.
2. Build the project (Project → Build).
3. Connect your board to your PC and flash (Run → Debug or use ST-Link utility).
4. Open a serial terminal at 9600 baud, type an answer, and press Enter.
Usage demo
- Power the board and open serial terminal. The LCD will show a question.
- Type "206" and press Enter. If correct, the green LED lights and a pleasant ding sequence plays. If wrong, the red LED lights and a low beep plays.
Video Demo
https://drive.google.com/file/d/1J-3u2UFI7LImi6mL_zV2R8tJtIgQzqxq/view







Comments