The HC-SR04 or Ultrasonic Distance Sensor can be connected to two digital pins of the EZ-B Robot Controller. If the distance sensor is mounted on a servo, this control will sweep the sensor back and forth in a scanning motion to detect objects.
It's worth noting that the distance displayed is not a unit of CM or Inches. The distance value is an arbitrary number that is related to the type of sensor, voltage, detected material, and temperature. If a specific distance is required, use a tape measure to identify the distance value.
If an object is detected, it is displayed by a little red dot similar to an army radar scanner. Optionally, you can use the Config menu to enable Movement Panel Control. With this option selected, this control will interact with a Movement Panel and steer your robot away from obsticles.
A great feature to enable is "Scan only when moving forward". This ensures the scanner and object collision detection is only enabled when the robot is moving.
*Note: If your robot does not have a servo attached to the distance sensor, then set the Servo port to NA.
These sensors can accurately detect an object within approximately 60 inches. Ultrasonic ping sensors are very accurate – they are not subject to interference from the sun. However, they do have trouble with some cloth materials.
The HC-SR04 ultrasonic sensor uses sonar to determine distance to an object, the same way that some animals like bats and dolphins do. It offers excellent range accuracy and stable readings in an easy-to-use package. Its operation is not affected by sunlight or black material, like Sharp rangefinders are (although acoustically soft materials like cloth can be difficult to detect). Similar in performance to the SRF005, but with the low-price of a Sharp infrared sensor.
The EZ-Robot Ultrasonic Distance Sensor comes in 2 versions. The first version, sold until February 10, 2017 uses 4 wires and an inline voltage regulator. The second version, available after February 10, 2017 uses 3 wires with a built-in voltage regulator in the plastic shell. The second version is updated and requires only a single plug to the EZ-B v4. We cover the installation of both sensor versions below...
This is the 3 wire version #2 (most recent) of the EZ-Robot Ultrasonic Distance Sensor. This version uses only 3 wires contained within a single connector. You may connect this version to any of the EZ-B v4 digital ports (D0-D23). In EZ-Builder, the values for both Ping and Echo can be selected for the same port.
This is the 4 wire version (older) of the EZ-Robot Ultrasonic Distance Sensor. This version has an inline voltage regulator and 4 separate wires. This version is a little more complex than the recent Version 2, due to separate wires and the inline voltage regulator.
- Ground = Black wire from regulator PCB to D21 black pin
- Power = Red wire from regulator PCB to D21 red pin
- Trigger = white wire to D21 White pin
- Echo = green wire to D22 White pin