Several people develop projects with robotics and one of the big problems is determining their navigation direction. In other words, the robot moves around the environment, but the system does not know its exact direction and this implies the process of its navigation.
As a solution, many people adopt the use of the GPS device to assist in the process of determining the direction. However, due to its commercial financial value, the project becomes more expensive and makes it impossible to use it to determine only the navigation direction.
In this case, the ideal is to use a magnetometer sensor. It has the ability to determine the direction of guidance from low financial investment in the project. That way, you will be able to determine your robot's navigation direction.
In this article, you will learn how to build your own digital compass with Arduino. Through it, you will be able to learn the complete operation of the HMC5883L sensor, to detect its orientation direction.
In addition, you will learn how to build your own electronic compass board and use it with your Arduino. In Figure 1 is shown the printed circuit board of the digital compassing.
Figure 1 - Printed Circuit Board of the Digital Compassing.
Therefore, at the end of the article you will have learned the following points:
- Creation of a digital compass with Arduino;
- Operation of the HMC5883L sensor;
- Creation of the Compass Printed Circuit Board with Arduino;
- Win the Compass printed circuit board files with Arduino.
This project will be divided into 3 important stages: Construction of the compass printed circuit board, Arduino circuit with the HMC5883L sensor and code for the Arduino to control the digital compass on the printed circuit board.
First, we are going to present the construction of the digital compass circuit. Next, we will present the circuit structure with the Arduino and the HMC5883L Magnetometer sensor.
To start the development of the printed circuit board of the digital compass, it was necessary to develop the circuit with 8 LEDs and a 9-pin male connector.
Each LED represents a specific direction of the compass rose. The circuit is shown in Figure 2.
Figure 2 - Electronic Schematic of the Digital Compassing.
After the construction of the electronic schematic, the electronic board was developed. The PCB design is shown in Figure 3.
Figure 3 - Printed Circuit Board of the Digital Compassing.
After the construction of the electronic board project, we can see its structure just below in Figure 4.
Figure 4 - Compass Rose PCB.
Now, I will show you how to build the circuit with the Arduino and the HMC5883L sensor. From this circuit, we will be able to detect the orientation of the robot and then activate the specific LED of the compass rose.
In the circuit below we present the Arduino Nano connected with the HMC5883L sensor.
The HMC5883L sensor is responsible for detecting the direction from North to South, and then the Arduino will receive and process this information.
From there, the Arduino will trigger one of the outputs from D2 to D9. These outputs will be connected to the board developed in step 1.
Therefore, each LED will represent a specific direction. The Electronic Schematic is presented in Figure 5,
Figure 5 - Electronic Schematic of the Arduino and Sensor HMC5883L.
Now, we'll present the programming of the project presented above.
First, we present the complete logic of the project's programming.
#include <Wire.h> //Biblioteca de Comunicacao I2C #include...Read more »