Dear fellow Hobbyist,
In this project we will explore the possibility of having an 360 degrees radar system for object detection. Having this module set separately will allow your locomotion robot to detect the boundaries of its surroundings. It can also serve as a navigational tool at dark, but only when you walk slow enough ;p
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: What You Will Need
To make this build you will need to buy the following :
Arduino Nano : https://www.ebay.com/itm/USB-Nano-V3-0-ATmega328-16M-5V-Micro-controller-CH340G-board-For-Arduino/201601613488?hash=item2ef0647eb0:g:DkoAAOSwvYZZpOl0:rk:2:pf:0
Prototyping Boards: https://www.ebay.com/itm/20pcs-set-4Size-Double-Side-Protoboard-Circuit-Universal-DIY-Prototype-PCB-Board/192076517108?epid=506557101&hash=item2cb8a70ef4:g:cQ4AAOSwN~Zbl232:rk:13:pf:0
Servo Motors : https://www.ebay.com/itm/5pcs-POP-9G-SG90-Micro-Servo-motor-RC-Robot-Helicopter-Airplane-Control-Car-Boat/142931003420?hash=item21475a081c:rk:16:pf:0&var
Ultrasonic Sensors: https://www.ebay.com/itm/5PCS-Ultrasonic-Sensor-Module-HC-SR04-Distance-Measuring-Sensor-for-arduino-SR04/170897438205?epid=18020663283&hash=item27ca47f5fd:g:w~IAAOSw--xbD5Fp:rk:2:pf:0
Step 2: Documentation
As some of you might already know this, this project is inspired from another open-source project called “Arduino Radar Project” made by Dejan from “How to Mechatronics” @ the following link: https://howtomechatronics.com/projects/arduino-radar-project/
Another point that requires documentation is to download the following two libraries into your development environment:
This being said, to really understand the C code you will need to do some documentation of both of the above libraries. Other than that, the functions I used in my code have names that are telltale to what they do.
Step 3: Prepare the Ultrasonic Sensor Support
Take any piece of cardboard and cut it according to the dimension of the connecting cables attached to the sensor as shown in the first picture. After that, fold this last and glue it to the servo motor support. Once that is done, glue the two ultrasonic sensors according to the last picture. Note that the header of the sensors should be soldered in a way to let the cables go outwards in front of the sensor. This will allow the sensor cables not to interfere with each other when the 360 degrees rotation is implemented.
Step 4: Mount Everything Into a Prototyping Board
In this step you will start by mounting the header prepared in the previous step into its respective servo motor. Once the servo motor is carefully accustomed, you will mount everything together into a prototyping board. You will start by soldering the Arduino Nano then by gluing the servo right next to it. Finally you will solder the small OLED display at the other edge of the board.
Step 5: Making the Final Connections
This step will conclude the hardware side of this project. You will need to follow the provided schematics to establish all the required connections.
Step 6: Booting the Program
There are Two codes that you will need to boot
Arduino (C) :https://github.com/ReconaissantL/RadarDuino/blob/master/radarduino.ino
Processing (java) :https://github.com/ReconaissantL/RadarDuino/blob/master/radarduino_java.pde
When running the code, you will have two options to choose from:
Option 1 : Using the OLED Display, for that you will need to set the variable MODE in the C code to 0.
Option 2 : Using Your Monitor, for that you will need to set the variable MODE in the C code to 1. In addition, you will need to download and install Processing development environment and download the radar font from this link: https://github.com/lastralab/ArduinoRadar/blob/ma...
And add that file to your processing code file so that your java code will recognize the font when called.
Step 7: Understanding the C Code
The code consists mainly of two ‘for’ loops. One is correlated with the forward pass while the other is with the backward pass. Inside both of them, the main function draw_scanner(), which will draw the lines of the radar onto the screen, is called many times. After testing multiple configurations, I came to the conclusion that we need to overwrite the white radar lines at time t with those same radar lines in black at time t+1 in order to delete them. If otherwise, flickering would occur everytime you clean the display using the function “clearDisplay()” before pushing the new pixel grid. As I was dealing with 7 lines – for design purposes- I had to keep saving and passing integer array of 7 elements, where each element stand for the radius between the center of the radar to the detected object, if any. With this in mind, the rest of the code should be straight forward to understand.
Step 8: Understanding the Java Code
In Processing, I had to bypass the function call for serialEvent(), which works only with serial ports named COM. As I was working on a Mac, my serial ports came under a different name. That being said, I unpacked that function into the main function in processing “draw()”. Regarding everything else, I have updated the application to meet the full revolution design. Finally, I updated all the drawn shapes and texts with the respect to the width of the screen so that the final product will fit different screen resolutions. I have personally tested it for both 1000X1000 and 500X500 resolutions, and it worked fine :) .
Step 9: Conclusion
This work can be upgraded to having 3 Ultrasonic sensors, each covering 120 view angle, or even 4 sensors (90 degrees*4) -> faster 360 deg. scan.
You can also extend the range of the radar from 40 cm to 60 cm or even 80 cm. I have personally tested the pulseIn function and adjusted the TIMEOUT variable with respect to 40 cm. This variable depends on many factors, including the length of the pulse send and the surface of the object where the pulse gets reflected.
Finally as stated before, the next step is to incorporate radarDuino with a locomotion robot to scan the surrounding perimeter.