This sketch measures the time taken for the ultrasound to return (in microseconds)Īnd then calculates the corresponding distance (based on the speed of ultrasound Takes data from a Vernier Motion Detector connected to BTD connector on Modified from Vernier example code: VernierMotionDetector (v 2013.11) Or, you use a Serial graphing program like SerialChart, MakerPlot, or write your own in Processing. You can copy-paste this into Excel, Matlab, or LoggerPro for analysis. Data will be displayed to the Serial Monitor. There are two variables declared in the beginning of the code that control these two parameters.Īfter uploading this file to your Arduino, open up a Serial Monitor and press the push button (D12) to start the data collection. This sketch will record at a dataRate of 20 samples per second for a duration of 5 seconds. The following code example has been adapted from the Vernier github repository. If you care to account for differences in temperature, hyperphysics has a great tool to calculate and adjust for differences in temperature. In our code, we assume that the speed of sound is nominally 340 m/s. If we assume that sound travels at a speed of about 340 m/s, this translates to a round-trip accuracy of better than 1 mm.īecause we know that sound travels at a constant speed in a uniform medium, we can use simple kinematics to determine the distance the reflected sound travelled. Using the Arduino function micros, we can catch the time of the echo to an accuracy of 1 us. Listen to this pin for the echo return / reflection. Trigger pin to send the ultrasonic pulse. On the Vernier shield, we have these pins tied to: Digital 1 The Vernier motion detector uses two pins for this: Init (Pin 2 on the BTD connector) It works by emitting an ultrasonic pulse and then listening for the echo of the pulse from the reflection off objects. The motion detector uses echo-location or sonar to determine the distance of objects in front of the sensor.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |