Ultrasonic Sensor


What is the Ultrasonic sensor ?

Ultrasonic sensor is a device that can measure the distance to an object by using sound waves

How does it work?

It measures distance by sending out a sound wave at a specific frequency and listening for that sound wave to bounce back. By recording the elapsed time between the sound wave being generated and the sound wave bouncing back, it is possible to calculate the distance between the sonar sensor and the object.

How to connect it ?

The Ultrasonic sensor has four pins as follow:

  • VCC: which is stand for the voltage, and it is connected to the 5V in the board.
  • Trig: is the pin that cause the module to send out a "Ping"
  • Echo: is the pin that receive the signal from the trig
  • GND: which is stand for the ground, and it is connected to G in the board 

You can connect it to the board directly using plug and play connectors to B1 or B2

How to program it ?

here is an example code