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

Navigation Systems with Arduino

Importance and usefulness of Navigation Systems

Navigation systems are essential tools in a wide range of applications, from autonomous vehicles to drones and even in everyday life with GPS navigation devices. These systems enable precise positioning, accurate movement control, and efficient path planning. By using an Arduino, we can easily create navigation systems for various purposes, making it a valuable skill for any electronics engineer.

Project: Autonomous Robot Navigation System

In this project, we will create an autonomous robot navigation system using an Arduino board. The objective is to enable the robot to move from one point to another while avoiding obstacles in its path. The system will utilize ultrasonic sensors to detect obstacles and control the robot's movements accordingly.

List of components:

  • Arduino Uno board x1
  • Ultrasonic sensor HC-SR04 x2
  • Motor driver L298N x1
  • DC motors x2
  • Wheels x2
  • 9V battery x1
  • Jumper wires

You can find these components online at the following links:

  • Arduino Uno: [link]
  • Ultrasonic sensor HC-SR04: [link]
  • Motor driver L298N: [link]
  • DC motors: [link]
  • Wheels: [link]
  • 9V battery: [link]
  • Jumper wires: [link]

Examples:

  1. Initializing the ultrasonic sensors:
    
    #include <NewPing.h>

define TRIGGER_PIN_1 2

define ECHO_PIN_1 3

define TRIGGER_PIN_2 4

define ECHO_PIN_2 5

NewPing sonar1(TRIGGER_PIN_1, ECHO_PIN_1); NewPing sonar2(TRIGGER_PIN_2, ECHO_PIN_2);

In this example, we include the NewPing library and define the trigger and echo pins for two ultrasonic sensors. The NewPing library simplifies the usage of ultrasonic sensors with Arduino.

2. Reading distance from the ultrasonic sensors:
```arduino
int getDistance(NewPing& sonar) {
  delay(50);
  int distance = sonar.ping_cm();
  return distance;
}

int distance1 = getDistance(sonar1);
int distance2 = getDistance(sonar2);

This code snippet defines a function to read the distance from a given ultrasonic sensor using the NewPing library. The function introduces a small delay to improve accuracy and returns the distance in centimeters. We then call the function for each sensor and store the distances in variables.

  1. Controlling the robot's movements based on sensor readings:
    
    #define MAX_DISTANCE 50
    #define MOTOR_SPEED 150

void moveForward() { // Code to move the robot forward }

void turnLeft() { // Code to turn the robot left }

void turnRight() { // Code to turn the robot right }

void stopMoving() { // Code to stop the robot's movement }

if (distance1 > MAX_DISTANCE && distance2 > MAX_DISTANCE) { moveForward(); } else if (distance1 <= MAX_DISTANCE && distance2 > MAX_DISTANCE) { turnRight(); } else if (distance1 > MAX_DISTANCE && distance2 <= MAX_DISTANCE) { turnLeft(); } else { stopMoving(); }


This code snippet demonstrates how to control the robot's movements based on the readings from the ultrasonic sensors. If both sensors detect distances greater than the maximum allowed distance, the robot moves forward. If one sensor detects an obstacle, the robot turns in the opposite direction. If both sensors detect obstacles, the robot stops moving.

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.