How to Build Your Own Arduino-Powered Mini Radar
If the video player is not working, you can click on this alternative video link.
Have need your own mini-radar system? Then why not consider making one of your very own!
In this short tutorial, we'll take you, step by step,(more or less) through the process.

Like any project of this nature, you are going to need a few bits and bobs. For this build, you will need:
- Arduino Nano
- HC-SR04 ultrasonic sensor
- SG90 servo motor
- 1.8" ST7735 Display (or equivalent)
- Soldering kit
- Screwdriver set
- 9V battery and connector
- Electrical wires and soldering gear.
- Assorted PCB wire female connectors and male pins.
- Slider switch
- A 3D printer, or ask a friend with one to help out
- Various 3D parts. The models for these are available here.
- Custom PCB board.
- Custom app
With all the materials needed in hand, it is time to get on with the build.
The first thing to do is print out the 3D part you'll need for this build. We have included the models above, but you can also find them here.

With the 3D part completed, it is time to turn our attention to this device's electronics. Gather together all the parts you need.

Next design for yourself, or copy, a custom PCB to fit all the components on. Watch the video for more details on this part.
You can find the wiring diagram here or check out the image below.

With your custom PCB in hand, add all the wiring connectors needed. Now, grab some wires, and wire up the LCD screen.
Try to use different colored wires for ease of reference later.

Now, grab your Arduino Nano, plug in the USB cable, and upload the code that will make your DIY radar system actually work. The code is fairly long and we have included it at the end of this tutorial.
You will also need to add this library to your Arduino IDE before compiling the code. Compile the code and upload it to the Nano ready for use later on.
With that step complete, now begin to add the components you need to the PCB. First, add the Arduino Nano to its respective slot and solder on the battery connector and switch.

With that step complete, place the PCB board inside the radar device's base.

Next, grab the wired up LCD screen and feed the wires through the stem of the base of the LCD screen mounting. Then secure the screen into place using the front faceplate -- screw-down, as required.

Next secure the LCD screen mounting assembly to the top plate of the radar's main housing. Wire up the other end of the LCD screen wires to a set of male connectors and connect to the main PCB.

Next, connect the battery -- but make sure the switch is set to off. Now, feed through the wires of the servo on the opposite side of the top plate to the LCD screen.
Wire it up to its respective slot on the PCB and fix the servo into place on the top plate.

Next, grab the ultrasonic sensor and insert it into the main radar dish 3D part.

Feed the sensor's wires through the neck of the base plate of the dish. Feed the wires through the same hole as the servo, and connect the dish's neck onto the servo motor.

Connect up the wires to the PCB board and close the top plate of the radar device, as shown in the video. It should fit snuggly onto the base.

Peel off the protective cover of the LCD screen and fire "her" up. Now begin to experiment with some objects for your master-crafted mini-radar system to detect!
Happy hunting.
As promised, here is the all important code for your DIY radar system. With the required library also installed, save the code as radar.ino:
#include .
#include
#include "Ucglib.h"
const int trigPin = 6;
const int echoPin = 5;
int Ymax = 128;
int Xmax = 160;
int base = 8;
int pos = base+6;
int deg=0;
int x;
int val =200;
int j = 2;
Servo myServo;
long duration;
int distance;
int k;
Ucglib_ST7735_18x128x160_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
void setup(void)
{
delay(1000);
myServo.write(80);
// ucg.begin(UCG_FONT_MODE_TRANSPARENT);
ucg.begin(UCG_FONT_MODE_SOLID);
ucg.setFont(ucg_font_6x10_tr);
ucg.clearScreen();
ucg.setRotate270();
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
Serial.begin(9600);
myServo.attach(3); // Defines on which pin is the servo motor attached
}
void loop(void)
{
fix();
for ( x=80; x >= 10; x--){
distance = calculateDistance();
Serial.println(distance);
k = map(x, 80, 10, 15,165);
myServo.write(k);
if (distance < 30){
int f = x+6;
ucg.setColor(255, 0, 0);
ucg.drawLine(Xmax/2, pos, -val*cos(radians(f*2)),val*sin(radians(f*2)));
}
ucg.setColor(0, 207, 0);
ucg.drawLine(Xmax/2, pos, -200*cos(radians(x*2)),200*sin(radians(x*2)));
int d = x+1;
ucg.setColor(0, 207, 0);
//ucg.drawLine(Xmax/2, pos, -200*cos(radians(d*2)),200*sin(radians(d*2)));
int c = x+2;
ucg.setColor(0, 207, 0);
//ucg.drawLine(Xmax/2, pos, -200*cos(radians(c*2)),200*sin(radians(c*2)));
int b = x+3;
ucg.setColor(0, 102, 0);
//ucg.drawLine(Xmax/2, pos, -200*cos(radians(b*2)),200*sin(radians(b*2)));
int a = x+4;
ucg.setColor(0, 102, 0);
//ucg.drawLine(Xmax/2, pos, -200*cos(radians(a*2)),200*sin(radians(a*2)));
int e = x+5;
ucg.setColor(0, 0, 0);
ucg.drawLine(Xmax/2, pos, -200*cos(radians(e*2)),200*sin(radians(e*2)));
ucg.setColor(255, 0, 0);
ucg.setPrintPos(160,0);
ucg.setPrintDir(2);
ucg.print("Deg :");
deg = map (x, 80, 10 , 0, 180);
ucg.setPrintPos(120,0);
ucg.setPrintDir(2);
ucg.print(deg);
ucg.setPrintPos(10,0);
ucg.print(distance);
ucg.setColor(0, 0, 255);
ucg.setPrintPos(90,38);
ucg.setPrintDir(2);
ucg.print("0.25");
ucg.setPrintPos(90,70);
ucg.print("0.50");
ucg.setPrintPos(90,110);
ucg.print("1.00");
}
// ucg.clearScreen();
fix();
for ( x=10; x <= 80; x++){
distance = calculateDistance();
Serial.println(distance);
k = map(x, 10, 80, 165,15);
myServo.write(k);
if (distance < 10){
int e = x-5;
ucg.setColor(255, 0, 0);
ucg.drawLine(Xmax/2, pos, -val*cos(radians(e*2)),val*sin(radians(e*2)));
}
ucg.setColor(0, 207, 0);
ucg.drawLine(Xmax/2, pos, -200*cos(radians(x*2)),200*sin(radians(x*2)));
int a = x-1;
//ucg.drawLine(Xmax/2, pos, -200*cos(radians(a*2)),200*sin(radians(a*2)));
int b = x-2;
ucg.setColor(0, 102, 0);
//ucg.drawLine(Xmax/2, pos, -200*cos(radians(b*2)),200*sin(radians(b*2)));
int c = x-3;
ucg.setColor(0, 102, 0);
//ucg.drawLine(Xmax/2, pos, -200*cos(radians(c*2)),200*sin(radians(c*2)));
int d = x-4;
ucg.setColor(0, 0, 0);
ucg.drawLine(Xmax/2, pos, -200*cos(radians(d*2)),200*sin(radians(d*2)));
ucg.setColor(255, 0, 0);
ucg.setPrintPos(160,0);
ucg.setPrintDir(2);
ucg.print("Deg :");
deg = map (x, 10, 80 , 0, 180);
ucg.setPrintPos(120,0);
ucg.setPrintDir(2);
ucg.print(deg);
ucg.setPrintPos(10,0);
ucg.print(distance);
ucg.setColor(0, 0, 255);
ucg.setPrintPos(90,38);
ucg.setPrintDir(2);
ucg.print("0.25");
ucg.setPrintPos(90,70);
ucg.print("0.50");
ucg.setPrintPos(90,110);
ucg.print("1.00");
}
//ucg.clearScreen();
}
void fix(){
ucg.setColor(255, 0, 0);
ucg.drawDisc(Xmax/2, base, 5, UCG_DRAW_LOWER_RIGHT);
ucg.drawDisc(Xmax/2, base, 5, UCG_DRAW_LOWER_LEFT);
ucg.setColor(225, 255, 50);
ucg.drawCircle(80, base, 115, UCG_DRAW_LOWER_RIGHT);
ucg.drawCircle(80, base, 115, UCG_DRAW_LOWER_LEFT);
ucg.drawCircle(80, base, 78, UCG_DRAW_LOWER_RIGHT);
ucg.drawCircle(80, base, 78, UCG_DRAW_LOWER_LEFT);
ucg.drawCircle(80, base, 40, UCG_DRAW_LOWER_RIGHT);
ucg.drawCircle(80, base, 40, UCG_DRAW_LOWER_LEFT);
ucg.drawLine(0, base, 160,base);
ucg.setColor(0, 0, 0);
ucg.drawBox(100, 0, 30, 8);
}
int calculateDistance(){
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH); // Reads the echoPin, returns the sound wave travel time in microseconds
distance= duration*0.034/2;
return distance;
}