Arduino with Ultrasonic Sensor HC-SR04

The HC-SR04 ultrasonic sensor uses SONAR to determine the distance of an object just like the bats do. It offers excellent non-contact range detection with high accuracy and stable readings in an easy-to-use package from 2 cm to 400 cm or 1” to 13 feet. The operation is not affected by sunlight or black material, although acoustically, soft materials like cloth can be difficult to detect. It comes complete with ultrasonic transmitter and receiver module. Follow the circuit diagram and make the connections as shown in the image given below. This code returns the distance in Inches... I think it's more accurate than other code I have seen online and returns more usable results. Write below program const int t1 = 7; const int p1 = 8; void setup() { Serial.begin(9600); pinMode(p1, INPUT); pinMode(t1, OUTPUT); } void loop() { long duration1, cm1; giveSignal(t1); duration1 = pulseIn(p1, HIGH)...