Skip to content

Instantly share code, notes, and snippets.


Paulami Paulami

View GitHub Profile
View hc-sr04.ino
/* HC-SR04 Sensor
This sketch reads a HC-SR04 ultrasonic rangefinder and returns the
distance to the closest object in range. To do this, it sends a pulse
to the sensor to initiate a reading, then listens for a pulse
to return. The length of the returning pulse is proportional to
the distance of the object from the sensor.
The circuit:
* VCC connection of the sensor attached to +5V
* GND connection of the sensor attached to ground