Ultrasonic Ranger

A ultrasonic ranger uses a ultrasonic wave to measure a distance.
Information

Type : Sensor

Mode : Digital

Pins : 0-14

Output Values : Distance in cm (2-300)

Tutorial : funduino

Note: To use this component use the two states to send and receive a wave!

Note: The read value needs to be transformed! See code below

Image by funduino, CC-BY-SA.

Connection scheme

Scheme made with Fritzing.

Functions

Send Wave

Send Wave State

Sends a ultrasonic wave.

void function_0_Ultraschall_messer(){
digitalWrite(pin_2_ultrasonicRanger, LOW);
delay(5);
digitalWrite(pin_2_ultrasonicRanger, HIGH);
delay(10);
digitalWrite(pin_2_ultrasonicRanger, LOW);
function_1_Ultraschall_messer();
}
  
digitalWrite(pin_2_ultrasonicRanger, LOW);
delay(5);
digitalWrite(pin_2_ultrasonicRanger, HIGH);
delay(10);
digitalWrite(pin_2_ultrasonicRanger, LOW);
  
void function_0_Ultraschall_messer(){
digitalWrite(pin_2_ultrasonicRanger, LOW);
delay(5);
digitalWrite(pin_2_ultrasonicRanger, HIGH);
delay(10);
digitalWrite(pin_2_ultrasonicRanger, LOW);
state = 1;
}
  

Receive Wave

Receive Wave State

Receive a ultrasonic wave.

void function_1_Ultraschall_messer(){
long pulseValueFromWave = pulseIn(pin_2_ultrasonicRanger, HIGH);
long value = (pulseValueFromWave/2) * 0.03432;
function_1_Ultraschall_messer();
}
  
long pulseValueFromWave = pulseIn(pin_2_ultrasonicRanger, HIGH);
long value = (pulseValueFromWave/2) * 0.03432;
  
void function_1_Ultraschall_messer(){
long pulseValueFromWave = pulseIn(pin_2_ultrasonicRanger, HIGH);
long value = (pulseValueFromWave/2) * 0.03432;
state = 1; 
}
  

Last modified April 12, 2022: updated code snippets (e7162de)