Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

Autonomous Navigation using Arduino and Ultrasonic Sensors

Importance and Utility of Autonomous Navigation

Autonomous navigation is a crucial aspect of robotics and automation. It allows robots to navigate their surroundings without human intervention, enabling them to perform tasks efficiently and accurately. This technology finds applications in various fields, including industrial automation, self-driving cars, and even home automation. By implementing autonomous navigation, robots can avoid obstacles, follow predefined paths, and interact with their environment intelligently.

Project: Autonomous Obstacle Avoidance Robot

In this project, we will build an autonomous robot capable of navigating a given environment while avoiding obstacles. The robot will use ultrasonic sensors to detect obstacles and adjust its path accordingly. The objective is to create a basic foundation for autonomous navigation, which can be further expanded and customized based on specific requirements.

List of Components:

  • Arduino Uno (1x) - [Link to purchase: example.com/arduino-uno]
  • Ultrasonic Sensor HC-SR04 (2x) - [Link to purchase: example.com/ultrasonic-sensor]
  • Motor Driver L293D (1x) - [Link to purchase: example.com/motor-driver]
  • DC Motors (2x) - [Link to purchase: example.com/dc-motor]
  • Chassis with Wheels (1x) - [Link to purchase: example.com/chassis-wheels]
  • Breadboard (1x) - [Link to purchase: example.com/breadboard]
  • Jumper Wires (Assorted) - [Link to purchase: example.com/jumper-wires]
  • 9V Battery (1x) - [Link to purchase: example.com/9v-battery]
  • Battery Connector (1x) - [Link to purchase: example.com/battery-connector]

Examples:

Example 1: Ultrasonic Sensor Setup

#include <NewPing.h>

#define TRIGGER_PIN 12
#define ECHO_PIN 11
#define MAX_DISTANCE 200

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);

void setup() {
  Serial.begin(9600);
}

void loop() {
  delay(50);
  unsigned int distance = sonar.ping_cm();
  Serial.print("Distance: ");
  Serial.print(distance);
  Serial.println(" cm");
}

This code sets up an ultrasonic sensor using the NewPing library. It measures the distance between the sensor and any obstacle in front of it and prints the distance in centimeters to the serial monitor.

Example 2: Autonomous Navigation with Obstacle Avoidance

#include <NewPing.h>

#define TRIGGER_PIN 12
#define ECHO_PIN 11
#define MAX_DISTANCE 200
#define MOTOR_PIN_1 5
#define MOTOR_PIN_2 6

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);

void setup() {
  pinMode(MOTOR_PIN_1, OUTPUT);
  pinMode(MOTOR_PIN_2, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  delay(50);
  unsigned int distance = sonar.ping_cm();
  Serial.print("Distance: ");
  Serial.print(distance);
  Serial.println(" cm");

  if (distance < 10) {
    // Obstacle detected, turn right
    digitalWrite(MOTOR_PIN_1, HIGH);
    digitalWrite(MOTOR_PIN_2, LOW);
  } else {
    // No obstacle, move forward
    digitalWrite(MOTOR_PIN_1, LOW);
    digitalWrite(MOTOR_PIN_2, HIGH);
  }
}

This code combines the ultrasonic sensor setup with motor control. The robot moves forward until an obstacle is detected within 10 cm. In such cases, it turns right to avoid the obstacle and then continues moving forward.

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.