Make your first project with an arduino UNO or any arduino, and a range finder sensor
Teacher Notes
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: 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
Step 2: Plug Your Sensor Into the Breadboard
Put your sensor into the breadboard along with 4 jumper wires.
Step 3: Attach to Arduino
Gnd - gnd Echo- digital pin 2 Trig - digital pin 3 Vcc - 5v
Step 4: Write the Code
Just copy from photo
Step 5: Plug in and Upload
Plug your arduino into your pc and upload. Open serial monitor in top right corner and have fun. You can use this with hundreds of projects good luck
1 Person Made This Project!
Sepius made it!
4 Discussions
3 years ago
Thanks supah,
Minor outputting improvement can be had with:
Serial.print(distance);
Serial.println(" cm");
4 years ago on Introduction
#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);
}
4 years ago on Introduction
Nice, simple, very well done.
4 years ago on Introduction
Excellent basic tutorial, it helped me set mine up with a minimum of problems.