CAPTCHA Machine Using Arduino Uno and OLED Display
by devkrishnavhora in Circuits > Arduino
33 Views, 0 Favorites, 0 Comments
CAPTCHA Machine Using Arduino Uno and OLED Display
The CAPTCHA Machine is an electronic project developed using an Arduino Uno, an OLED display, two push buttons, and an LED. The project generates random mathematical questions and asks the user to select the correct answer from three options.
The OLED display shows the question and its possible answers. The user navigates between the options using the NEXT button and selects an answer using the SUBMIT button. If the selected answer is correct, the display shows "CAPTCHA PASSED!" and "ACCESS OK". If the answer is incorrect, the display shows "WRONG ANSWER!" and "TRY AGAIN".
This project demonstrates how an Arduino can generate random questions, process user input, and provide visual feedback.
Supplies
Deshbot shield
uno nano
oled display
Circuit Connections
OLED Display
OLED PinArduino Uno Pin
VCC - 5V, if supported by the OLED module
GND = GND
SDA = A4
SCL=A5
Push Buttons and LED
ComponentArduino Uno Pin
NEXT Button = D10
SUBMIT Button =D12
LED Signal = D11
The buttons use the Arduino's internal pull-up resistors through INPUT_PULLUP. Connect each button between its assigned digital pin and GND.
LED note: The code treats D11 as a single LED output. If using a bare LED, connect it through a suitable current-limiting resistor. If using an RGB LED, this code controls only one channel; separate pins are required to control red, green, and blue independently.
Working Principle
The system operates in the following sequence:
- The Arduino Uno initializes the OLED display and configures the push buttons and LED.
- A starting message appears on the OLED screen.
- The Arduino generates a random mathematical question.
- Three answer options are created, including one correct answer and two incorrect answers.
- The OLED displays the question and all three answer options.
- The user presses the NEXT button to move the selection marker between the answers.
- The user presses the SUBMIT button to check the selected answer.
- If the answer is correct, the system displays a success message.
- If the answer is incorrect, the system displays a failure message.
- After the message disappears, a new CAPTCHA question is generated.
The LED turns on while either button is pressed and turns off when both buttons are released.
Types of CAPTCHA Questions
The program generates five types of mathematical questions:
S. No.Question TypeExample
1
Addition
5 + 7 = ?
2
Multiplication
4 × 6 = ?
3
Number Sequence
3, 5, 7, ?
4
Square Number
5 squared = ?
5
Subtraction
18 − 6 = ?
The numbers change randomly when a new question is generated.
Program Description
generateCaptcha()
This function randomly selects a question type, generates the question, calculates its correct answer, and creates three answer options. The correct answer is placed at a random position.
displayCaptcha()
This function clears the OLED screen and displays the CAPTCHA title, mathematical question, and three answer options. An arrow indicates the currently selected answer.
showSuccess()
This function displays "CAPTCHA PASSED!" and "ACCESS OK" when the user selects the correct answer. After a short delay, the system generates another question.
showFailure()
This function displays "WRONG ANSWER!" and "TRY AGAIN" when the user selects an incorrect answer. After a short delay, another question appears.
setup()
This function initializes the buttons, LED, Serial communication, and OLED display. It also initializes the random number generator and displays the startup message.
loop()
This function continuously reads the button states, updates the LED, moves the selected answer when NEXT is pressed, and checks the selected answer when SUBMIT is pressed.
Button Debouncing
The program uses a debounce delay to reduce unwanted repeated button actions caused by mechanical button contacts.
Expected Output
Startup Screen
The OLED displays:
CAPTCHA MACHINE
Starting...
Question Screen
An example question screen is:
CAPTCHA MACHINE
5 + 7 = ?
Choose answer:
- 12
- 9
- 15
The arrow indicates the currently selected option.
Correct Answer
When the user selects the correct answer and presses SUBMIT, the OLED displays:
CAPTCHA PASSED!
ACCESS OK
Incorrect Answer
When the user selects an incorrect answer and presses SUBMIT, the OLED displays:
WRONG ANSWER!
TRY AGAIN
After a short delay, a new question appears.
Downloads
Conclusion
The CAPTCHA Machine demonstrates how an Arduino Uno can generate random mathematical questions, display multiple-choice answers, read user selections, and verify responses. The project combines OLED interfacing, push-button inputs, random number generation, and conditional logic in an interactive embedded system.
It provides a useful foundation for developing more advanced quiz systems, electronic games, and simple verification demonstrations. Future improvements could include separate red and green LED indicators, increasing difficulty levels, a score counter, and a limited number of attempts.