Arduino OLED Math Quiz

Recently, I was tinkering with a small I2C OLED screen and Arduino. It was quite interesting to see the AdafruitGFX library following the core principles of 'Processing'. Before implementing a rather not very intuitive game using the OLED screen like the snake game or brick breaker, I decided to start with a text-based game.

A simple, fun to play randomly generated math quiz! The game uses a potentiometer and a push-button for user input (though a rotary encoder would've been a more logical option). For every five questions answered correctly, the game levels up, increasing the variety of questions.
The game starts with a splash screen that can be customized by using a bitmap generator.


Splash Screen

Use 10k resistors to pull up SDA and SCK (Optional)



Parts Required-

  1. 0.96″ OLED Display Module I2C -128×64 
  2. An Arduino board 
  3. A potentiometer (any value between 10k to 100k)
  4. A pushbutton 
  5. 2 x 10k resistors (optional)
  6. Patience (you may require a lot of it)
Here's the schematic, as always, made with fritzing (Open Source is ๐Ÿ’™)-




If your screen seems to flicker, you may want to add 10k pull-up resistors for SDA and SCK.

Finally, the Arduino code-


The code uses two libraries- 
1. A general library for displaying graphics on various displays-AdafruitGFx
2. A library for the OLED display- Adafruit SSD1306
If you'd like to explore how to display custom graphics and fonts on the OLED display, here's the way.
If you wish to add more question-answer templates, scroll down to the definition of newQuestion() in the code and follow the format of the previous questions.
The huge array of hexadecimal numbers ( 0x00, 0xFF .......) is the bitmap for the splash screen logo. As mentioned earlier, this website converts JPEG images to bitmaps, use it to create your own splash screen!

All feedback is always appreciated in the comments below๐Ÿ˜ƒ

Stay Creative!

Comments