Hello, in our first article, we will make an Arduino Distance sensor. Let’s get started right away!

Necessary Materials

  1. Arduino Uno (Arduino Nano, Arduino Mega etc.)
  2. Nokia 5110 LCD
  3. HC-SR04
  4. Breadboard
  5. Assorted Jumper Cable

The Nokia 5110 screen is a frequently used element in hobby projects with its cheap price and easy to use. The display is an 84×48 pixel graphic LCD screen powered by 3.3V, likewise the HC-SR04 is one of the most popular sensors used with the Arduino in robotic projects. It is very easy to use and can measure distances between 2cm and 400cm properly as long as the program part is smooth.

Here we will measure the distance with the ultrasonic sensor and display it on the LCD screen.

If you want to download the project as a ZIP file, you can download it from the GitHub page by clicking this link.

Installation of Libraries

To use the Nokia 5110 LCD screen, we download the library from here, in the same way, to use the HC-SR04 sensor, we download the library from here.

If you don’t know the library installation, you can check this page.

Now that we have completed our library installation process, you need to make the connections of the circuit as follows.

Connection Diagram

If you don't see the image, please let know in the comments!


Now that we’ve made the connections, we can move on to coding.

// Date: 23.02.2020
#include <LCD5110_Basic.h>

#define trigPin 7
#define echoPin 6

LCD5110 lcd(8, 9, 10, 11, 12);

extern uint8_t SmallFont[];
extern uint8_t BigNumbers[];

void setup() {

  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);

void loop() {
  lcd.print("Distance:", CENTER, 0);
  int duration, distance = 0;

  digitalWrite(trigPin, HIGH);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = duration / 58;

  lcd.printNumI(distance, CENTER, 16);


Yes, it should work without problems. In this first article, we made the distance sensor with Arduino. I hope it has been a project that will interest you. Stay healthy… 🙂