EasyManua.ls Logo

SunFounder GalaxyRVR - Page 65

Default Icon
120 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
SunFounder GalaxyRVR Kit for Arduino, Release 1.0
Imagine our superhero, the HC-SR04 Ultrasonic Sensor, playing a game of echo in the mountains.
First, our superhero’s brain, the MCU, says, “Ready, Set, Go!” by sending out a high-level signal for at least 10
microseconds to our superhero. This is like when we gather our energy before we yell into a valley.
On hearing “Go!”, our superhero shouts out loud 8 times very quickly. This super-sonic shout is sent out at a
speed of 40 kHz. The superhero also starts a stopwatch and keeps an ear out for any returning shouts.
If there is an obstacle in front, the shout will hit it and echo back. On hearing the echo, our superhero stops the
stopwatch and notes the time. It also sends out a high-level signal to let the MCU know it heard an echo.
Lastly, to find out how far away the obstacle is, our superhero uses a simple formula. It takes the time it recorded
on the stopwatch, divides it by 2, and multiplies it by the speed of sound (340m/s). The result is the distance to
the obstacle!
Thats how our superhero sensor can figure out if theres an obstacle in its path and how far away it is. Amazing, isn’t
it? Next, we’ll learn how we can use this superhero power in our Mars Rover!
Step 3: Coding Our Superhero Sensor
Having assembled our superhero sensor and understood how it uses its superpowers, it’s time to put those powers into
action! Lets write an Arduino sketch to allow our ultrasonic sensor to measure distances and then show us those
measurements.
Here are the key steps that our superhero sensor will follow:
We have connected both the TRIG and ECHO pins to pin 10 on the GalaxyRVR Shield. This allows us to control
both signal transmission and reception of the ultrasonic module using a single Arduino pin.
3.7. Lesson 7: Enhancing Rover Navigation with Ultrasonic Module 61

Related product manuals