Arduino Motor Radar

by Itzlit17 in Circuits > Arduino

385 Views, 1 Favorites, 0 Comments

Arduino Motor Radar

IMG_8708.jpeg

This is a radar made with Arduino, this Radar allows users to detect objects.

Supplies

The materials needed:

Arduino Board

Servo motor

HC-SR04 Ultrasonic sensor

Breadboard

Jumper wires

IMG_8707.jpeg

Have the sensor and the motor ready, then glue the lego stand on the motor. Stick the sensor to the lego pieces.

Arduino Picture .jpeg

Connect all the jumper wires on the Arduino board.

(Changed)

Arduino Code:

#includeconst int TriggerPin = 8;
const int EchoPin = 9;

const int motorSignalPin = 10;

const int startingAngle = 90;

const int minimumAngle = 10;

const int maximumAngle = 140;

const int rotationSpeed = 3;

Servo motor;

void setup(void) { pinMode(TriggerPin, OUTPUT);

pinMode(EchoPin, INPUT);

motor.attach(motorSignalPin);

Serial.begin(9600);

} void loop(void) { static int motorAngle = startingAngle; static int motorRotateAmount = rotationSpeed;

motor.write(motorAngle);

delay(10);

SerialOutput(motorAngle, CalculateDistance());

motorAngle += motorRotateAmount;

if(motorAngle <= minimumAngle || motorAngle >= maximumAngle) { motorRotateAmount = -motorRotateAmount;

}} int CalculateDistance(void) { digitalWrite(TriggerPin, HIGH);

delayMicroseconds(10); digitalWrite(TriggerPin, LOW); long duration = pulseIn(EchoPin, HIGH); float distance = duration * 0.017F; return int(distance);

} void SerialOutput(const int angle, const int distance) { String angleString = String(angle); String distanceString = String(distance); Serial.println(angleString + "," + distanceString);

}

Credits

IMG_8705.jpeg
IMG_8706.jpeg

Thanks to JohnM1579 for the awesome idea

Link: https://www.instructables.com/Arduino-Radar-1/#di...

Arduino Instructables

Video

Arduino Radar