My project is about a pong game on an 0.96 oled display useing the arduino uno r3 and 2 side buttons to control it!
🛠️ เจาะลึกเบื้องหลังการทำงาน (Deep Dive / Technical Analysis)
The OLED Pong Game is a marvel of miniaturization. By utilizing the I2C protocol and specific display libraries, you can render smooth, 60 FPS graphics on a screen smaller than a postage stamp.
Graphic Engine on Arduino
Driving an OLED screen requires a "Frame Buffer."
- The Buffer: The Arduino allocates a chunk of its SRAM (1024 bytes for a 128x64 display) to act as an invisible canvas.
- Drawing: Functions like
display.fillRect()calculate the math of the paddle and the ball, flipping bits in that invisible canvas. - The Push: The
display.display()command sends all 1024 bytes to the OLED screen in a split second, creating a smooth visual frame.
Essential Hardware
- Arduino Uno/Nano: The processor.
- 0.96" I2C OLED (SSD1306): The tiny screen.
- Two Potentiometers: Used to slide the paddles up and down the Y-axis.
- A piezo buzzer: For satisfying "blip" noises when the ball bounces.
Why use Potentiometers?
While buttons work, potentiometers provide smooth analog input. The Arduino's ADC converts the twist of the knob (0-1023) directly into the Y-coordinate of the paddle (0-64), creating the exact feel of a classic 1970s arcade cabinet dial.