HC-SR04 Ultrasonic Sensor Module

  • ₹ 95.00
  • Save ₹ 104


Ultrasonic ranging sensor available at Tomson Electronics, Kochi, Kerala, India is an economical sensor module that provides 2cm to 400cm of non-contact measurement functionality with a ranging accuracy that can reach up to 3mm. Each HC-SR04 module includes an ultrasonic transmitter, a receiver and a control circuit.
There are only four pins that you need to worry about on the HC-SR04: VCC (Power), Trig (Trigger), Echo (Receive), and GND (Ground). You will discover this sensor simple to set up and use for your next range-discovering venture utilizing an Arduino or Raspberry Pi.


Use the following code to integrate Arduino with your Ultrasonic sensor to calculate the distance of objects.


* Ultrasonic Sensor HC-SR04 Arduino Tutorial
* Crated by Tom,
* www.tomsonelectronics.com
// defines pins numbers
const int trigPin = 9;
const int echoPin = 10;
// defines variables
long duration;
int distance;
void setup() {
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
Serial.begin(9600); // Starts the serial communication
void loop() {
// Clears the trigPin
digitalWrite(trigPin, LOW);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
distance= duration*0.034/2;
// Prints the distance on the Serial Monitor
Serial.print("Distance: ");


Operating Voltage: 5V DC
Operating Current: 15mA
Measure Angle: 15°
Ranging Distance: 2cm - 4m


We Also Recommend