Arduino Radar using Arduino Nano and TFT screen

In this Arduino Tutorial I will show you how you can make this cool looking Arduino Radar using the Arduino nano & the Arduino TFT screen. The following video shows the results of this project, read the tutorial below for more details.


All you need for this Arduino project is an Ultrasonic Sensor for detecting the objects, a small hobbyist Servo Motor for rotating the ultrasonic sensor and an Arduino Board for controlling them.

When you have finished reading this tutorial, you will be familiar with:

  • Connecting and using a Arduino TFT screen
  •  Connecting and using a Ultrasonic sensor
  • Connecting and using a Servo motor

What You Will Need

We will need the following parts and libraries in this tutorial:



The following libraries will be used in this tutorial. Please refer to this tutorial on how to add an Arduino library in eclipse

We will be using Eclipse for Arduino, if you haven’t setup please refer to my previous tutorial on eclipse for Arduino.

Circuit Schematics

Connect the Ultrasonic Sensor HC-SR04 to the pins number 2 and 3 and the servo motor to the pin number 6 on the Arduino Nano Board. Then connect the Arduino TFT screen according to my previous tutorial here.

Source Code

The project has the following workflow: First the Arduino triggers the servo to move into an angle between 0 and 180 degrees then commands the ultrasonic sensor to measure distance of the obstacle if the obstacle is within the beam radius of 100 cm we draw a red otherwise we draw a green radial line.

Now let’s take a look at the code. So first we need to include the libraries for the TFT module, ultrasonic sensor and the servo motor, then  define some variables needed for the program below as well as create the instances of the libraries

In the setup section, first we initialize the TFT module, servo motor and the ultrasonic sensor, and  then set the background color of the screen to BLACK.

In the loop section, we start by drawing the green arc of our radar zone

In the following for loop we trigger the servo to move from left to right by 1 degree and then get the ultrasonic sensor data


Then we draw the line from the center of the radar zone to the point corresponding to degree the servo has moved

where 80, 128 is the center of the radar zone and  80 + r_beam * cos( ( 360 – i ) * 3.14 / 180 ) and  128 + r_beam * sin( ( 360 – i ) * 3.14 / 180 ) give us the corresponding x and y coordinate on the screen that marks the end of the line.

After that we then test the value of the ultrasonic sensor to check if the obstacle is within the radar zone. If this is true we draw a red circle marking the distance of the obstacle from the center of the radar zone

This process is repeated for the reverse movement of the servo motor

So that’s pretty much everything and here’s the complete code of the project:.

2 thoughts on “Arduino Radar using Arduino Nano and TFT screen”

  1. Hi.
    Radar lines shows objects on 0,5m distance. How can I change it to full scanning scale?

    int r = distance * 2;
    String r_Printout = String( r / 2 );

    I’ve played with these codes and it affected the graphic but the cm text has effected too. I’m new to Arduino and trying to learn.

    1. Please ensure you are doing the changes in both for loops i.e. clockwise and counter clockwise for loops. I think that might help
      Or share code snip and i look at it

Comments are closed.