ULTRASONIC SENSOR

TINKS002

  1. As the name indicates, ultrasonic sensors measure distance by using ultrasonic waves.
  2. The sensor head emits an ultrasonic wave and receives the wave reflected back from the target.
  3. Ultrasonic Sensors measure the distance to the target by measuring the time between the emission and reception.
  4. Ultrasonic sensor provides a Digital output.
Features:-
  1. Operating voltage: +5V
  2. Theoretical Measuring Distance:2cm to 450cm
  3. Practical Measuring Distance:2cm to 60cm
  4. Accuracy:3mm
  5. Measuring angle covered:<15°
  6. Operating Current:<15mA
  7. Operating Frequency:40Hz.
  8. Output :-Digital
Applications:-
  1. Used to avoid and detect obstacles with robots like biped robot, obstacle avoider robot, path finding robot etc.
  2. Used to measure the distance within a wide range of 2cm to 400cm
  3. Can be used to map the objects surrounding the sensor by rotating it
  4. Depth of certain places like wells, pits etc. can be measured since the waves can penetrate through water.

    

int echoPin=3;

int trigPin=2;

long duration;

int distanceCm;

void setup() {

  // put your setup code here, to run once:

pinMode(trigPin,OUTPUT);

pinMode(echoPin,INPUT);

Serial.begin(9600);

}

 void loop() {

  // put your main code here, to run repeatedly:

digitalWrite(trigPin,LOW);

delayMicroseconds(2);

 

digitalWrite(trigPin,HIGH);// sets trig pin high only for 10 seconds

delayMicroseconds(10);

digitalWrite(trigPin,LOW);

 

duration=pulseIn(echoPin,HIGH);

distanceCm=duration*0.034/2;

 

Serial.print("DISTANCE IN CM: ");

Serial.println(distanceCm);

delay(200);

 }