[vc_row][vc_column width=”1/1″][vc_column_text]Ultrasonic sensors (also known as transceivers when they both send and receive, but more generally called transducers) work on a principle similar to radar or sonar which evaluate attributes of a target by interpreting the echoes from radio or sound waves respectively. Ultrasonic sensors generate high frequency sound waves and evaluate the echo which is received back by the sensor. Sensors calculate the time interval between sending the signal and receiving the echo to determine the distance to an object.
This technology can be used for measuring wind speed and direction (anemometer), tank or channel level, and speed through air or water. For measuring speed or direction a device uses multiple detectors and calculates the speed from the relative distances to particulates in the air or water. To measure tank or channel level, the sensor measures the distance to the surface of the fluid. Further applications include: humidifiers, sonar, medical ultrasonography, burglar alarms and non-destructive testing.
Systems typically use a transducer which generates sound waves in the ultrasonic range, above 18,000 hertz, by turning electrical energy into sound, then upon receiving the echo turn the sound waves into electrical energy which can be measured and displayed.
[/vc_column_text][vc_tour][vc_tab title=”BOM” tab_id=”1384376914-1-88″][vc_column_text]1. Arduino Uno experiment platform
2. Ultrasonic sensor breakout
3. Jumper wire[/vc_column_text][/vc_tab][vc_tab title=”Wire Diagram” tab_id=”1384376914-2-63″][vc_column_text][/vc_column_text][/vc_tab][vc_tab title=”Explaination” tab_id=”1384377143706-2-5″][vc_column_text]After wire everything, and upload the code to Arduino Uno, open the serial port monitor, and we will observe the distance measured.[/vc_column_text][/vc_tab][vc_tab title=”Sample Code” tab_id=”1384377184456-3-6″][vc_column_text]
const int TrigPin = 2;
const int EchoPin = 3;
float cm;
void setup()
{
Serial.begin(9600);
pinMode(TrigPin, OUTPUT);
pinMode(EchoPin, INPUT);
}
void loop()
{
digitalWrite(TrigPin, LOW);
delayMicroseconds(2);
digitalWrite(TrigPin, HIGH);
delayMicroseconds(10);
digitalWrite(TrigPin, LOW);
cm = pulseIn(EchoPin, !(LOW)) / 58.0; //map the time to centimeter
cm = (int(cm * 100.0)) / 100.0; //keep two digits after the decimal point
Serial.print(cm);
Serial.print("cm");
Serial.println();
delay(1000);
}
We can download the code here (HC_SR04 ).
[/vc_column_text][/vc_tab][/vc_tour][/vc_column][/vc_row]
Leave a Reply
You must be logged in to post a comment.