Making Arduino based radar with Nokia 5110 LCD:
In this article we will learn about the how to make a radar using Arduino and Nokia 5110 LCD display. This is a very easy project and easy to understand how to work and how to make this project..
Now lets Talk about the major components regarding to this project
COMPONENS FOR RADAR:
- ARDUINO UNO BuyNow
- NOIKA 5110 LCD BuyNow
- SERVO MOTOR BuyNow
- ULTRASONIC SENSOR BuyNow
- BREAD BOARD BuyNow
- CONNECTIN WIRES BuyNow
If you want to buy Arduino components, I am giving my affiliate links. If you buy the components using my affiliate links, it will help to our channel and website growth. so do these small help.
what is radar?
do you want to know more details about the radar click on here
HOW THIS PROJECT WORKS :
simply I'm explain about this project.. when any obstacle or anything will be closer to the radar then it will detect that and show the direction of that thing in NOIKA5110 display
video:
CIRCUIT DIAGRAM :
Connect the all components as shown in the below circuit diagram
after successfully completed the connections of components now its time to upload the code on Arduino
CODE :
#include <Arduino.h>
#include <SPI.h>
#include <U8g2lib.h>
#include <Servo.h>
U8G2_PCD8544_84X48_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 8, /* data=*/ 9, /* cs=*/ 11, /* dc=*/ 10,/* reset=*/ 12); // Nokia 5110 Display
Servo Servo1;
const int servoPin = 6;
//for sonar
const int triggerPin = 4;
const int echoPin = 3;
int distance;
int locationOfObjects[180];
void drawDial(int angle) {
u8g2.drawCircle(42, 48, 41, U8G2_DRAW_ALL);//center(42,48) radius:41
u8g2.drawCircle(42, 48, 31, U8G2_DRAW_ALL);//center(42,48) radius:31
u8g2.drawCircle(42, 48, 21, U8G2_DRAW_ALL);//center(42,48) radius:21
u8g2.drawCircle(42, 48, 11, U8G2_DRAW_ALL);//center(42,48) radius:11
int x = 42 - 41 * cos(angle * 3.14 / 180);
int y = 48 - 41 * sin(angle * 3.14 / 180);
u8g2.drawLine(42, 48, x, y);
}
void drawObjectLine(int value, int angle) {
int x0 = 42 - 41 * cos(angle * 3.14 / 180);
int y0 = 48 - 41 * sin(angle * 3.14 / 180);
int x1 = 42 - value * cos(angle * 3.14 / 180);
int y1 = 48 - value * sin(angle * 3.14 / 180);
u8g2.drawLine(x1, y1, x0, y0);
}
int getDistance() {
long duration;
digitalWrite(triggerPin, LOW);
delayMicroseconds(2);
digitalWrite(triggerPin, HIGH);
delayMicroseconds(10);
digitalWrite(triggerPin, LOW);
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
return duration * 0.034 / 2;
}
void clearArray() {
for (int i = 0; i < 180; i++) {
locationOfObjects[i] = 0;
}
}
void setup(void) {
u8g2.begin();
Servo1.attach(servoPin);
Serial.begin(9600);
}
void loop(void) {
for (int i = 0; i < 180; i++) {
Servo1.write(i);
u8g2.clearBuffer();
drawDial(i);
distance = getDistance();
if (distance < 30) {
locationOfObjects[i] = distance;
} else {
locationOfObjects[i] = 0;
}
for (int k = 0; k < i; k++) {
if (locationOfObjects[k]) {
drawObjectLine(locationOfObjects[k], k);
}
}
u8g2.sendBuffer();
delay(50);
}
clearArray();
for (int i = 180; i > 0; i--) {
Servo1.write(i);
u8g2.clearBuffer();
drawDial(i);
distance = getDistance();
if (distance < 30) {
locationOfObjects[i] = distance;
} else {
locationOfObjects[i] = 0;
}
for (int k = 180; k > i; k--) {
if (locationOfObjects[k]) {
drawObjectLine(locationOfObjects[k], k);
}
}
u8g2.sendBuffer();
delay(50);
}
clearArray();
}
you can download the code by click on here
If you have any doubts about this project . Write the problem in the comment section either in YouTube or this blog i will help my best
0 Comments