To buy sensor you can visit www.vegarobokit.com
Arduino Code:
#define echoPin 7
#define trigPin 6
void setup()
{
Serial.begin(9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
void loop()
{
int distance,duration;
digitalWrite(trigPin, HIGH);
delay(100);
digitalWrite(trigPin, LOW);
duration=pulseIn(echoPin, HIGH);
distance=(duration/2)/29.1;
Serial.print(distance);
Serial.print("CM");
Serial.println("");
delay(100);
}
![](https://s2.save4k.ru/pic/HvJq0M29bFU/maxresdefault.jpg)