loading
Picture of Arduino Range Finder Tutorial
Make your first project with an arduino UNO or any arduino, and a range finder sensor

Step 1: Make Sure You've Got Everything!

Picture of Make Sure You've Got Everything!
Your gunna need- 4 jumper wires 1 arduino ( I used UNO) 1 breadboard 1 data cable to program the arduino 1 hc-sro4 sensor
 
supah4x0r4 months ago

#define trigPin 3

#define echoPin 2

void setup()

{

Serial.begin(9600);

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

}

void loop()

{

int duration, distance;

digitalWrite(trigPin, HIGH);

delayMicroseconds(2000);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distance = (duration/2) / 29.1;

Serial.println(distance);

Serial.print("cm");

delay(500);

}

supah4x0r4 months ago

Nice, simple, very well done.

JoeS98 months ago

Excellent basic tutorial, it helped me set mine up with a minimum of problems.