Projects / Pocket game on a Nokia screen

Pocket game on a Nokia screen

Beginner1.5 hGuided buildReviewed

Build it step by step

0 of 8 done
  1. NANO

    Power the display

    VCC to 3.3V, GND to GND, backlight through 330 ohm to 3.3V.

  2. NANO

    Wire the signals

    CLK, DIN, DC, CE and RST each through 10 kilohm to D7, D6, D5, D4 and D3.

  3. NANO

    Wire the buttons and buzzer

    D8 and D9 to GND, buzzer on D10.

  4. NANO

    Upload the sketch

    The ball starts moving.

  5. NANO

    Use the up and down buttons

    The paddle moves.

  6. NANO

    Return the ball

    The score goes up with a beep.

  7. NANO

    Miss the ball

    GAME OVER appears.

  8. NANO

    Press a button

    A new game starts.

In short

How do you build a pocket game on a Nokia screen?

A Nokia 5110 screen and two buttons make a small Pong game. You need Arduino Nano, Nokia 5110 LCD (PCD8544), Tactile push button 6 mm × 2, Passive buzzer, Resistor 330 Ω, Resistor 10 kΩ × 5, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm). It takes 8 steps and about 90 minutes.

Level
Beginner
Time
About 90 min
Parts
8

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
Display VCCNano 3.3VThe screen runs on 3.3 V
Display GNDNano GNDGround
Display backlightNano 3.3V through 330 ohmDim backlight
Display CLKNano D7 through 10 kilohmSeries resistor drops the 5 V signal
Display DINNano D6 through 10 kilohmData
Display DCNano D5 through 10 kilohmData or command
Display CENano D4 through 10 kilohmChip select
Display RSTNano D3 through 10 kilohmReset
Up buttonNano D8 to GNDMove the paddle up
Down buttonNano D9 to GNDMove the paddle down
Passive buzzer plusNano D10Beeps

Code

The Nokia 5110 display has 84 by 48 pixels and is driven by the PCD8544 chip, which uses a simple serial protocol. It works at 3.3 volts, while the Nano's outputs are 5 volts, so each signal goes through a 10 kilohm resistor in series and the display's own input protection handles the small excess current. A bidirectional level shifter is the safer choice if you plan to leave it running for long. The game keeps a ball and a paddle as numbers and redraws the whole screen thirty times a second. The ball bounces off the top, bottom and right wall, and bounces off the paddle with an angle that depends on where it hits and a small speed-up each time. If it passes the paddle the game ends, and a press of either button restarts. Beeps from the passive buzzer give each event its own pitch. Try adding a second paddle for a two-player game or a high score saved in EEPROM. Adjust setContrast if the screen looks blank or too dark.

Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>

Adafruit_PCD8544 lcd(7, 6, 5, 4, 3);       // CLK, DIN, DC, CE, RST
const int UP = 8, DOWN = 9, BUZZER = 10;

const int W = 84, H = 48;
const int PADDLE_H = 10;
float px = 2, py = 19;
float bx, by, vx, vy;
int score = 0;
bool over = false;

void serve() {
  bx = 20; by = 24;
  vx = 1.2; vy = (random(2) ? 0.8 : -0.8);
}

void drawAll() {
  lcd.clearDisplay();
  lcd.fillRect((int)px, (int)py, 2, PADDLE_H, BLACK);
  lcd.fillRect((int)bx, (int)by, 2, 2, BLACK);
  lcd.drawFastVLine(W - 1, 0, H, BLACK);       // right wall
  lcd.setCursor(40, 0);
  lcd.setTextSize(1); lcd.setTextColor(BLACK);
  lcd.print(score);
  if (over) { lcd.setCursor(14, 20); lcd.print("GAME OVER"); }
  lcd.display();
}

void setup() {
  pinMode(UP, INPUT_PULLUP);
  pinMode(DOWN, INPUT_PULLUP);
  pinMode(BUZZER, OUTPUT);
  lcd.begin();
  lcd.setContrast(55);
  randomSeed(analogRead(A0));
  serve();
}

void loop() {
  if (over) {
    drawAll();
    if (digitalRead(UP) == LOW || digitalRead(DOWN) == LOW) { score = 0; over = false; serve(); delay(300); }
    return;
  }
  if (digitalRead(UP) == LOW   && py > 0)             py -= 2;
  if (digitalRead(DOWN) == LOW && py < H - PADDLE_H)  py += 2;

  bx += vx; by += vy;
  if (by <= 0 || by >= H - 2) { vy = -vy; tone(BUZZER, 800, 20); }
  if (bx >= W - 3)            { vx = -vx; tone(BUZZER, 600, 20); }
  if (bx <= px + 2 && bx >= px && by + 2 >= py && by <= py + PADDLE_H) {
    vx = fabs(vx) * 1.05;                              // bounce and speed up a little
    vy += ((by - (py + PADDLE_H / 2)) * 0.08);          // angle depends on where it hits
    score++;
    tone(BUZZER, 1200, 30);
  } else if (bx < 0) {
    over = true; tone(BUZZER, 200, 300);
  }
  drawAll();
  delay(30);
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Power onBall moves and the paddle responds
Hit the ballScore increases
MissGame over and a low tone
Press a button after game overRestart
Long gameBall speeds up slowly

If it does not work

Screen blank

Raise or lower setContrast and check the 3.3 V supply.

Garbled screen

Check the order of CLK, DIN and DC and the reset wire.

Buttons do nothing

Check they go to D8 and D9 and GND.

Ball too fast

Lower the starting vx or the speed-up factor.

Display hot or dim

Check the series resistors and the backlight resistor.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the pocket game on a Nokia screen?

Arduino Nano, Nokia 5110 LCD (PCD8544), Tactile push button 6 mm × 2, Passive buzzer, Resistor 330 Ω, Resistor 10 kΩ × 5, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm).

How long does the pocket game on a Nokia screen take to build?

About 90 minutes for a beginner maker, in 8 steps.

How do I know the pocket game on a Nokia screen works?

Power on: Ball moves and the paddle responds. Hit the ball: Score increases. Miss: Game over and a low tone.

Screen blank: what should I check?

Raise or lower setContrast and check the 3.3 V supply.

Garbled screen: what should I check?

Check the order of CLK, DIN and DC and the reset wire.

Buttons do nothing: what should I check?

Check they go to D8 and D9 and GND.

Ball too fast: what should I check?

Lower the starting vx or the speed-up factor.