This tutorial will demonstrate how an Arduino, sensors, and Processing were used to build a robot with built-in visual sonar system. The sensor is made to rotate around 180 degrees by incorporating the Arduino which will be used to control a servo. Along with the current angle of the servo to the serial port, the Arduino will then send the value from the distance sensor.For visualization, the code for Processing is used since it is an easy to learn programming tool. As shown below, the Processing gathers the sonar data from the Arduino and its sensors and then displays it on the screen.
One of the Arduino radar parts used is the SRF-05 ultrasonic range finder or distance sensor which has a wide field of detection. The servo and the SRF-05 are sharing the power that is being provided by the Arduino to the breadboard. As shown in the images below, the SRF-05 pins are going to digital pin 2 and 3 and the servo output pin going to Arduino digital pin 9.
From the 2 servos shown in the photo, the sensor can be rotated around by just using the bottom one of the pair. A lot of blu-tac has been used to mount the sensor onto the servo wheel vertically which lessens the interference with receiving values when the servo moves. The modeling clay holds them down in place and there’s a difference between the first and second readings when the sensor is placed horizontally.
Rotating the servo from left to right and then right to left is the hardest part as well as taking a series of readings for every degree of movement and sending them to the serial port. To produce an average reading value for consistency, it has to be quite slow when getting accurate values with this ultrasound sensor. In order to produce the average value, the signal should be allowed for some time to come back each time and register.
To read and interpret the values from the servo and the sensor, a radar screen to visualize sensor data has to be made. False distance readings may result to not allowing enough time to the signals to be sent back. The Processing code is as good as the Arduino code and sensor setup. To ensure that the data sent by the Arduino can be read, the variables and background have to be set up and loaded in the serial port libraries. To get the servo position and sensor value, some easy string work and splitting the serial port line have to be done. The X and Y coordinates of each servo position and sensor distance reading needs to be calculated throughout.
The SRF-05 works best as a static range finder as it emits a conical wave which will bounce back off of anything small or large and has a widen detection field of vision as shown in the video below. The detection range is so wide and does not truly see all the gaps while detecting something else in its file of vision, as illustrated in the image below.
To see if better results are obtained on the radar styled display, sharp infrared range finder can be used. The display has been altered to measure only up to 150cm because the IR sensor has a different range. To avoid seeing spikes, any value recorded outside of this range needs to be handled because of this range limitation. The same size screen and are kept to the make the display more readable. To magnify them a bit more, the sensor values are multiplied by 2 as shown below.