![]() One opening transmits ultrasonic waves, (like a tiny speaker), the other receives them, (like a tiny microphone). The Ultrasonic Sensor sends out a high-frequency sound pulse and then times how long it takes for the echo of the sound to reflect back. Your computer, a USB wall charger, or a USB power bank.Īs you move your hand or feet further away from the front of the sensor, the speaker will play tones that increase in pitch and timing. Plug the arduino into a USB power source. object we take half of the distance travelled. The ping travels out and back, so to find the distance of the The speed of sound is 340 m/s or 29 microseconds per centimeter. Long microsecondsToCentimeters(long microseconds) and return, so we divide by 2 to get the distance of the obstacle. This gives the distance travelled by the ping, outbound According to Parallax's datasheet for the PING))), there are ![]() Long microsecondsToInches(long microseconds) to notes on a piano you can do this instead but not necessarily have frequencies that correspond if you want the sound to just change based on distance, PinMode (4, INPUT) //attach pin 4 to EchoĬm = microsecondsToCentimeters(duration) of the ping to the reception of its echo off of an object. pulse whose duration is the time (in microseconds) from the sending The same pin is used to read the signal from the PING))): a HIGH PinMode(3, OUTPUT) // attach pin 3 to Trig Give a short LOW pulse beforehand to ensure a clean HIGH pulse: The PING))) is triggered by a HIGH pulse of 2 or more microseconds. and the distance result in inches and centimeters: establish variables for duration of the ping, musical instrument for HC-SR04 (4 pin) Ultrasonic Sensor Open up the Arduino IDE you downloaded and installed earlier.Įither download the attached file "piano.ino" and open it with the Arduino IDE app, or just paste the below indentical code there:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |