Good night,
Going on with my adventures with Arduino and sensors, today I decided to play with Ultrasonic sensor HC-SR04 to measure distance.
HC-SR04 is pretty easy to work with, it has 4 pins, VCC to energy, Trig to start a measurement, Echo to get the distance, and GND to ground.
It has a library to get it working, it is called Ultrasonic. The only problem that I had was the Library is out of date, it still uses WProgram.h but Arduino 1.0.1 uses Arduino.h, so I updated it. (You can get on the end of the post).
The library must be included on your dir “arduino-1.0.1/libraries” and you must restart your IDE.
Sensor VCC connects to Arduino +5V pin
Sensor Trig connects to Arduino PIN 12
Sensor Echo connects to Arduino PIN 13
Sensor GND connnects to Arduino GND PIN
You can configure it on trig and echo variables.
[code lang=”c”]
#include “Ultrasonic.h”
int trig = 12;
int echo = 13;
Ultrasonic ultrasonic(trig,echo);
void setup() {
Serial.begin(9600);
}
void loop()
{
Serial.print(“Distance CM:”);
Serial.println(ultrasonic.Ranging(CM));
Serial.print(“Distance INC:”);
Serial.println(ultrasonic.Ranging(INC));
delay(100);
}
[/code]
Referências:
HC-SR04 DataSheet
Biblioteca Ultrasonic atualizada para Arduino 1.0.1
https://ijpsgtibdd.wordpress.com
https://ijpsgtibdd.wordpress.com
https://bbudktdhdo.wordpress.com
https://bbudktdhdo.wordpress.com
https://tqjhrbjrzv.wordpress.com
https://txxbdjbcir.wordpress.com
https://txxbdjbcir.wordpress.com
https://ckbsqizjpk.wordpress.com
https://ckbsqizjpk.wordpress.com
1win мегапей пополнение https://www.1win63197.help
mostbet пополнение без комиссии http://mostbet38195.help
https://ckbsqizjpk.wordpress.com
https://olyfufoizv.wordpress.com
https://olyfufoizv.wordpress.com
https://olyfufoizv.wordpress.com
pinup roʻyxatdan oʻtish bepul https://pinup35741.help/
hogyan regisztráljak a mostbet oldalon hogyan regisztráljak a mostbet oldalon
1win blackjack strategiya https://1win57196.help
1win şifrə tələbləri http://1win57196.help
pin up Namangan pin up Namangan
pin-up aviator demo https://pinup35741.help
https://mjejtbdecc.wordpress.com
melbet elsom melbet elsom
https://snduazsogv.wordpress.com
https://wccpcrdyhx.wordpress.com
mostbet android üçün mostbet https://mostbet31847.help/
mostbet způsoby platby mostbet způsoby platby
https://wccpcrdyhx.wordpress.com
https://wccpcrdyhx.wordpress.com
https://wccpcrdyhx.wordpress.com
https://yjcftkejiq.wordpress.com
https://yjcftkejiq.wordpress.com
мелбет регистрация на русском мелбет регистрация на русском
https://qwofcxhwfl.wordpress.com
https://qwofcxhwfl.wordpress.com
https://qwofcxhwfl.wordpress.com
mostbet bónuszkód beváltás mostbet bónuszkód beváltás
mostbet live http://mostbet2019.help
mostbet rəsmi sayt linki http://mostbet31847.help
https://yrzssotfpy.wordpress.com
mostbet ajánlatok https://mostbet2021.help
1win пополнение без комиссии элсом 1win пополнение без комиссии элсом
1win мобильная версия http://www.1win41825.help
https://xhlvpqtyim.wordpress.com
https://xhlvpqtyim.wordpress.com
https://xhlvpqtyim.wordpress.com
melbet retragere neteller http://www.melbet63048.help
https://hbpjncswpf.wordpress.com
https://hbpjncswpf.wordpress.com
1win turnee Moldova 1win turnee Moldova