Introduction: RadArduino - Radar Made With Arduino Leonardo and Processing 3

Hi everyone.

This project is a sonar (Sound Navigator And Ranging) that we have implemented with a Arduino Leonardo and we have depicted in Processing 3.

It is part of the subject 'Creative Electronics', a Beng Electronics Engineering 4th year module at the University of Málaga, School of Telecommunications (www.etsit.uma.es).

Its works in the following way:

A stepper motor rotate 360º sideways, and when reaches the end, change the direction and rotate another 360º. The reason why the motor doesn’t move is because is pinned to the base. While stepper motor is rotating, the ultrasonic sensor collects information constantly. This information is sent to Processing through the serial port.

The program that we have created in Processing have two ways for representing the data collected. The first one is with lines and the second draws circles at the distance that ultrasonic sensor has detected the object. The representation mode it can be changed if we press key “space bar”. When we change the representation mode, the radar is calibrates automatically with the encoder installed.

At the starting, the radar doesn't do anything until the Processing code runs and send the signal to start. That way Arduino and Processing initiate at the same time.

Before start explaining the steps, you can play the video at the top to see how it works running all together.

You maybe should check our Git Hub repository too.

Step 1: Bill of Materials (BOM)

BOM for RadArduino proyect:

- SAV MAKER 1 or Arduino Leonardo

- 1 can

- Ultrasonic sensor HC-SR04

- Stepper motor 28BYJ-48 with the controler ULM2003A

- LDR: Light Dependent Resistor

- Diode LED

- Socle

- Resistances: 220 ohms and 10 kohms

- Wires

- Glue

- Hard carton

- Bottle cap

Step 2: Make the Container and the Structure

For make the container, we have used a container of coffee, but can be used any cylindrical container. The container should have between 15-20 cm in height and totally empty.

We have to trim the sheet on the base, that you can see in the second image, in order to not bother with cables. the final result is shown by the last image.

At the lower parte of the container, we made little gap to extract the cables that go to Arduino and the controller of the stepper motor.

The structure is made with hard carton. We have to trim a circular base with the diameter of the container, and do a triangular cut to put the bracket of stepper motor. The bracket is a small triangular structure of hard carton, where we attach the stepper motor. We have to keep in mind, that the shaft of the stepper motor should be in the middle of the container.

Finally, with the cover of the container, we make a base to put the ultrasonic sensor and one diode led. We have make a hole in the middle of the cover and glue a bottle cap with other rectangular hole, in the same way of shaft, in the middle. This way, the shaft of the stepper motor fits better and it is stronger. In one edge of the cover, we have to do a cut to put a socle, where will go the ultrasonic sensor, a resistor and a led for the encoder.

Step 3: Add an Encoder With a LDR Sensor and One Diode LED

The encoder has been made using a diode led and a LDR (Light Dependent Resistor).

To make this, we have to pierce the container and put the LDR in the hole. This point (where the LDR is) will be the front of the radar.

The diode led is placed in the cover at the same socle as the ultrasonic sensor is. When the motor rotates, the diode crosses by the front of the LDR and Arduino detects it. This new function allows the system to know where the radar front is.

Step 4: Circuit

The circuit is mounted on a little breadboard as you can see in the photos.

In the fritzing circuit, you can see where the wires are connected. It's more visual.

LDR is mounted in a voltage divider configuration (5 V. -> LDR -> A0 -> 10K resistor -> GND).

Stepper motor connection is different because we've used a pcb which includes the ULN2003A controller. Anyway, the connection is quite easy.

Step 5: Arduino Code.

In this step, arduino code is slightly commented because it is fully explained. This explanations are in the code file. Anyway, it is quite easy.

There are three important blocks which are mixed in the code:

The fisrt one is related with the motor control. The code is based in this one (http://www.prometec.net/motor-28byj-48/). It's a spanish web but the code is very clear and useful (greetings to the author). The motor look for the radar front (where LDR is), his rotation is faster when it's doing a calibration. When the front is found, the rotation is quite slow (this is a nice effect!). Half steps configuration is the chosen one because the rotation is really soft.

In the second block the HC-SR04 sensor is configurated using a library called NewPing (It's attached). NewPing library is really useful and it allows to control the sensor easily.

The third block is related with the communication through the serial port. Proximity information is sended by the port. Processing program send commands through this port too (start command and mode commnads).

If you have some doubts, we'll try to answer you asap.

Step 6: Processing Code

In this step, we attach the proccesing code. This code take cares of showing the data collected by the radar (HC-SR04 sensor) in a nice interface that simulates an original radar.

The functions we use, take part of proccesing references and they are explained in their web page (https://processing.org/reference/).

One important thing to say is that the processing code isn't work without the radar and the arduino code. It can't start until the RadArduino is running. Also it depends of arduino sending the data collected to print the radar lines. This way, the two parts will be synchronized and the data will be show in the right position.

As we said in the previous step, if you have any doubts write us and we'll try to answer it.

Step 7: This Is the End

It's all. I hope you like it and if you have any doubts, we'll answer you!

We'll be very pleased if you leave us a comment giving your opinion.

Greetings!