0% found this document useful (0 votes)
29 views5 pages

Ultrasonic Radar

The document outlines the creation of an Ultrasonic Radar Object Detection System using components like Arduino Nano, ultrasonic sensors, and an OLED display. It details the wiring instructions, programming code for Arduino, and a Java simulation for detecting objects based on distance measurements. The project aims to detect objects within a specified range and display their distance on an OLED screen, with potential for further enhancements.

Uploaded by

gawdeshraddha562
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views5 pages

Ultrasonic Radar

The document outlines the creation of an Ultrasonic Radar Object Detection System using components like Arduino Nano, ultrasonic sensors, and an OLED display. It details the wiring instructions, programming code for Arduino, and a Java simulation for detecting objects based on distance measurements. The project aims to detect objects within a specified range and display their distance on an OLED screen, with potential for further enhancements.

Uploaded by

gawdeshraddha562
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Project Title: Ultrasonic Radar Object Detection System

Objective:

To build a radar-like system that detects objects within a specified range and provides information
about the object's distance and size.

Components Required:

 Arduino Nano (3 units)

 Ultrasonic Sensor (HC-SR04) - Can be substituted with your available Force Sensor

 NodeMCU ESP8266 (1 unit)

 OLED Display (0.96" I2C) (1 unit)

 Servo Motor (1 unit)

 Jumper Wires

 Breadboard

 Power Supply (like a 5V battery)

Project Description:

The system will use an ultrasonic sensor to measure the distance to an object. It will then display this
information on an OLED screen. The servo motor can be used to rotate the sensor, allowing it to
scan a wider area.

Circuit Diagram:

Wiring Instructions:

1. Ultrasonic Sensor:

o VCC to 5V on NodeMCU

o GND to GND on NodeMCU

o Trig to D1 on NodeMCU

o Echo to D2 on NodeMCU

2. OLED Display:

o VCC to 5V on NodeMCU

o GND to GND on NodeMCU

o SDA to D3 on NodeMCU

o SCL to D4 on NodeMCU

3. Servo Motor:

o Red Wire (Power) to 5V

o Black Wire (Ground) to GND


o Control Wire to D5 on NodeMCU

Programming:

1. Install Arduino IDE and add the necessary libraries for the OLED display and ultrasonic
sensor.

2. Use the following code as a starting point:

cpp

Copy code

#include <Wire.h>

#include <Adafruit_GFX.h>

#include <Adafruit_SSD1306.h>

#include <Servo.h>

#define TRIG_PIN D1

#define ECHO_PIN D2

#define OLED_RESET -1

Adafruit_SSD1306 display(OLED_RESET);

Servo myServo;

void setup() {

Serial.begin(115200);

pinMode(TRIG_PIN, OUTPUT);

pinMode(ECHO_PIN, INPUT);

display.begin(SSD1306_I2C_ADDRESS, OLED_RESET);

myServo.attach(D5);

display.clearDisplay();

void loop() {

for (int angle = 0; angle <= 180; angle += 15) {

myServo.write(angle);
delay(500);

long duration, distance;

digitalWrite(TRIG_PIN, LOW);

delayMicroseconds(2);

digitalWrite(TRIG_PIN, HIGH);

delayMicroseconds(10);

digitalWrite(TRIG_PIN, LOW);

duration = pulseIn(ECHO_PIN, HIGH);

distance = duration * 0.034 / 2; // Calculate distance in cm

display.clearDisplay();

display.setCursor(0,0);

display.print("Distance: ");

display.print(distance);

display.println(" cm");

display.display();

Testing:

1. After uploading the code, power the system.

2. Move objects in front of the ultrasonic sensor to see the distance displayed on the OLED
screen.

3. The servo motor will rotate and allow you to detect objects in different directions.

Conclusion:

This Ultrasonic Radar Object Detection System allows you to detect and measure the distance of
objects in its path. You can further enhance this project by adding features like logging data, creating
alerts for nearby objects, or integrating more sensors.

JAVA :
Sure! Here's a basic Java code snippet that simulates the functionality of the Ultrasonic Radar Object
Detection System using the components you have. Since the actual interfacing with hardware
components is typically done using C/C++ on Arduino, the Java code here is more of a simulation to
illustrate how you might handle the logic and display output.

If you're using the NodeMCU (ESP8266) and want to control it via Java, you could create a web
application where the NodeMCU serves data over Wi-Fi. However, for direct Arduino interfacing, you
would generally use the Arduino IDE with C/C++.

Java Code Simulation

java

Copy code

import java.util.Random;

public class UltrasonicRadar {

// Method to simulate getting distance from the ultrasonic sensor

public static double getDistance() {

Random random = new Random();

return 20 + (random.nextDouble() * (200 - 20)); // Random distance between 20cm and 200cm

// Method to simulate detecting an object

public static String detectObject(double distance) {

if (distance < 50) {

return "Object detected within 50cm!";

} else if (distance < 100) {

return "Object detected at a safe distance.";

} else {

return "No object detected.";

public static void main(String[] args) {

while (true) {
double distance = getDistance();

System.out.println("Distance: " + distance + " cm");

String detectionMessage = detectObject(distance);

System.out.println(detectionMessage);

// Simulate a delay

try {

Thread.sleep(2000); // Delay for 2 seconds before the next reading

} catch (InterruptedException e) {

e.printStackTrace();

How This Code Works:

1. getDistance(): Simulates the distance measurement. In a real setup, this would interface
with the ultrasonic sensor.

2. detectObject(): Checks the distance and returns a message based on whether an object is
detected or not.

3. main(): Continuously reads the distance, checks for objects, and prints the results to the
console.

Running the Code:

 You can run this Java code in any Java IDE or command line environment with Java installed.

 Remember, this is a simulation. In a real application, you would replace the distance
measurement part with actual sensor readings.

Connecting with NodeMCU:

If you want to control the radar system via the NodeMCU, you would typically write the logic in C++
using the Arduino IDE and set up a web server on the NodeMCU to send data to a Java application if
needed.

You might also like