High-Level Project Summary
In this project, we will learn how to use an Ultrasonic Sensor with an Arduino to survey the surrounding space.
Link to Project "Demo"
Link to Final Project
Detailed Project Description
Connect the circuit as shown in the following figure:

programming :
We will write a program that sends a signal to rotate the servo motor at a certain angle and calculate the distance in front of the sensor at that angle. These results are then sent to the serial port.
Instead of reading these results on the Serial Monitor, we run Matlab. In Matlab, we create a special code to be run to perform some calculations and then give a simple outline of the place map.
#include <Servo.h>
#include <NewPing.h>
#define TRIGGER_PIN 12
#define ECHO_PIN 11
#define MAX_DISTANCE 200
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
Servo myservo;
int pos = 0;
int it = 10;
void setup() {
myservo.attach(9);
Serial.begin(9600);
delay(3000);
}
void loop() {
int i = 0;
int t = 0;
int a = 0;
for (i = 0; i < 180; i ++)
{
unsigned int uS = sonar.ping();
myservo.write(i);
delay(20);
for (t = 0; t < it; t++)
{
uS = sonar.ping();
a = uS/US_ROUNDTRIP_CM + a;
delay(30);
}
a = a / (it-1);
t = 0;
Serial.println(a);
a = 0;
}
}
Space Agency Data
Hackathon Journey
So good
Tags
#nasa
Global Judging
This project has been submitted for consideration during the Judging process.

