Implementing Pong with Arduino Nano and I2C OLED 128x64

benjamin woehrl
2 min readNov 23, 2016

I have been flirting with the idea of implementing some little gadgets based on the Arduino for a long time. Because of its small dimensions and the ATmega328 I ordered an Arduino Nano - More information about the Arduino Nano.

In order to get the process going, I wanted to operate with an I2C OLED Display, a LED, a Switch and a Potentiometer. After I have hooked up and tested those connections, I intended to implement a two player pong, using the mentioned pheripheries.

In the following sections I will show you the process of building the game. If you are familiar with basic knowledge in dealing with circuits and resistors, the hardware implementation is pretty much straightforward. Alternatively, you can find tons of great and useful articles on the internet.

Enough said… let´s go!

Components

As already mentioned, we need for our little Pong revival the following components:

  • Arduino Nano ATmega328 — LINK
  • OLED 128x64 I2C Display (128x64) — LINK
  • 2 Controllers (10k potentiometer)
  • Status-LED
  • Switch
  • 2 resistors: 4,7K Switch, 1K LED

Wiring

http://fritzing.org

Code implementation

I have created a public github repository with my project code. Feel free to clone, fork or create a pull request to push the project!

https://github.com/ruction/arduino-pong

The code shouldn´t require any explanation. Further, the tricky parts are described in the comments.

Dependencies

Beside the Wire.h, for the I2C communication, there are two more libraries which are necessary for the OLED support:

If you are not familiar with the process of including new libraries to your arduino project, I recommend: https://www.arduino.cc/en/Guide/Libraries

Now, connect your Arduino Nano together with the connected separates (see Wiring) to your computer and run the Arduino software.

And here is my final result!I hope you like my project.

So long… See ya!

--

--

benjamin woehrl

Co-Founder of Conntac - The Self-Service Company / Developer & Design Enthusiast