This is a Chrome-Dino-style game for an Arduino Uno. The OLED shows the game, the TM1637 display shows the score, the rotary encoder button makes the Dino jump, and the buzzer produces game sounds.
Below is the complete wiring diagram setup for the project:
- Arduino Uno R3
- 128x64 OLED Display (I2C)
- TM1637 4-Digit Segment Display
- KY-040 Rotary Encoder
- Piezo Buzzer
- Arduino Uno
- USB data cable
- SH1106 128x64 OLED display
- TM1637 four-digit display
- KY-040 rotary encoder
- Buzzer
- Jumper wires and a breadboard
- Arduino IDE
flowchart LR
A[Rotary Encoder Button] --> B[Dino Game on Arduino Uno]
B --> C[SH1106 OLED\nGame Scene]
B --> D[TM1637 Display\nScore]
B --> E[Buzzer\nSound]
Connect the components exactly as shown below before powering the board.
| Component | Component Pin | Arduino Uno Pin |
|---|---|---|
| Rotary encoder | SW | D3 |
| Rotary encoder | DT | D4 |
| Rotary encoder | CLK | D2 |
| Rotary encoder | VCC | 5V |
| Rotary encoder | GND | GND |
| TM1637 display | DIO | D5 |
| TM1637 display | CLK | D6 |
| TM1637 display | VCC | 5V |
| TM1637 display | GND | GND |
| Buzzer | Signal / positive | D10 |
| Buzzer | GND / negative | GND |
| OLED | SDA | A4 |
| OLED | SCL | A5 |
| OLED | VCC | 5V |
| OLED | GND | GND |
flowchart TB
UNO[Arduino Uno]
ENC[KY-040 Rotary Encoder]
OLED[SH1106 OLED]
SCORE[TM1637 4-Digit Display]
BUZZ[Buzzer]
ENC -->|SW to D3| UNO
ENC -->|DT to D4| UNO
ENC -->|CLK to D2| UNO
OLED -->|SDA to A4| UNO
OLED -->|SCL to A5| UNO
SCORE -->|DIO to D5| UNO
SCORE -->|CLK to D6| UNO
BUZZ -->|Signal to D10| UNO
ENC -.->|VCC and GND| UNO
OLED -.->|VCC and GND| UNO
SCORE -.->|VCC and GND| UNO
BUZZ -.->|GND| UNO
- Download and install Arduino IDE from the official Arduino website.
- Open Arduino IDE after installation.
- Use a USB data cable, not a charge-only cable.
Arduino IDE sketches must be inside a folder with the same name as the .ino file.
Create this folder structure:
Dino/
├── Dino.ino
├── TM1637Display.cpp
├── TM1637Display.h
└── README.md
In Arduino IDE, select File > Open, open the Dino.ino file, and keep all three source files in the same Dino folder.
- Open Sketch > Include Library > Manage Libraries.
- Search for
U8glib. - Install the library named U8glib.
- Close and reopen Arduino IDE if the library is not detected immediately.
The local TM1637Display.cpp and TM1637Display.h files are already included in this project. They do not need to be installed separately.
- Connect the Arduino Uno to the computer.
- Open Tools > Board > Arduino AVR Boards > Arduino Uno.
- Open Tools > Port and select the port labelled
Arduino Uno. - On Windows, the port can be checked in Device Manager > Ports (COM & LPT).
flowchart LR
A[Install Arduino IDE] --> B[Open Dino.ino]
B --> C[Install U8glib]
C --> D[Select Arduino Uno]
D --> E[Select COM Port]
E --> F[Verify Code]
F --> G[Upload to Board]
- Open
Dino.inoin Arduino IDE. - Confirm that
TM1637Display.cppandTM1637Display.hare in the same folder. - Select the Arduino Uno board.
- Select the correct COM port.
- Click the checkmark button, or choose Sketch > Verify/Compile.
- Wait for the message
Done compiling. - Click the right-arrow Upload button, or choose Sketch > Upload.
- Wait for
Done uploading. - The Arduino Uno will restart and the game will begin on the OLED.
sequenceDiagram
participant PC as Arduino IDE
participant USB as USB Cable
participant UNO as Arduino Uno
PC->>PC: Verify / Compile
PC->>USB: Send compiled program
USB->>UNO: Upload Dino game
UNO->>UNO: Restart and run setup()
UNO->>UNO: Run game loop
Test the project in this order after uploading the code:
- Open
Dino.inoin Arduino IDE. - Click Verify.
- The bottom panel must show
Done compilingwithout red errors.
- Keep the Arduino connected by USB.
- The OLED should show
Welcome to Dino!!andPush to begin. - The TM1637 display should be on and ready to show the score.
- If the OLED is blank, turn off power and recheck
SDA,SCL,VCC, andGND.
- Press the rotary encoder button once.
- The welcome screen should change to the running game.
- Press the button again while the Dino is running.
- The Dino should jump and the buzzer should make a short sound.
- Leave the Dino running without pressing the button.
- The number on the TM1637 display should increase.
- The cactus obstacles should move from right to left on the OLED.
- Let the Dino hit an obstacle.
- The OLED should show the game-over screen and the buzzer should sound.
- Press the rotary encoder button after game over.
- The welcome screen should appear again.
- Start the game once more and confirm that the score starts from zero.
flowchart TD
A[Click Verify] --> B{No compile errors?}
B -- No --> C[Install U8glib or fix the shown error]
B -- Yes --> D[Upload to Arduino Uno]
D --> E[OLED welcome screen]
E --> F[Press encoder button]
F --> G[Test jump, score, buzzer, and obstacles]
G --> H[Collision shows game over]
H --> I[Press button to restart]
If the IDE is open but nothing is happening, check these items in order:
- Make sure the USB cable supports data transfer.
- Check that the Arduino power light is on.
- Select Arduino Uno under Tools > Board.
- Select the correct COM port under Tools > Port.
- Close Serial Monitor before uploading.
- Press the Arduino Uno reset button once, then upload again.
- Disconnect and reconnect the USB cable.
- If the COM port is missing, install the USB driver used by your Arduino board.
- Compile first with Verify. Fix any error shown in the bottom output panel before uploading.
- Press the rotary encoder button to start.
- Press the same button while playing to jump.
- Avoid the cactus obstacles.
- The score increases while the Dino survives.
- After a collision, press the button to return to the start screen.
Dino.ino: game states, animation, collision detection, score, input, and sound.TM1637Display.h: interface for the local TM1637 score-display driver.TM1637Display.cpp: communication and digit encoding for the TM1637 display.README.md: wiring and Arduino IDE instructions.
Install U8glib from Sketch > Include Library > Manage Libraries, then compile again.
Move TM1637Display.cpp and TM1637Display.h into the same folder as Dino.ino.
Close Serial Monitor and any other program using the COM port. Select the correct port and upload again.
Turn off the Arduino, recheck SDA, SCL, VCC, and GND wiring, then power it on again.
