Sensor Tutorial HC-SR04 Linkit One

Introduction: Sensor Tutorial HC-SR04 Linkit One

About: Thank you instructables!!

In this tutorial I will make a simple project using hc-sr04 and linkit one board giving you an idea about using it.The L.E.D glows whenever an object comes in between the specified distance.Her is a video of it working:-

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: Things Requires

We need :-

  1. Linkit one board
  2. Jumper wires
  3. Hc-Sr04 ultrasonic distance sensor
  4. Battery
  5. USB cord
  6. L.E.D

Step 2: Pin Configuration

Insert all jumper wires one by one in the 4 pins of sensor,2 terminals of L.E.D .

  1. Connect -ve terminal of L.E.D to gnd
  2. Connect +ve terminal of L.E.D to digital pin
  3. echo to 12
  4. trig to 13
  5. vcc to +5
  6. gnd to gnd

Step 3: Code

#define trigPin 13

#define echoPin 12 #define led 11

void setup() { Serial.begin (9600); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); pinMode(led, OUTPUT);


void loop() { long duration, distance; digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH);

delayMicroseconds(10); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); distance = (duration/2) / 29.1; if (distance < 50) { digitalWrite(led,HIGH);

}else { digitalWrite(led,LOW); } if (distance >= 200 || distance <= 0){ Serial.println("Out of range"); } else { Serial.print(distance); Serial.println(" cm"); } delay(800); }

Step 4: Done!

I hope this will help you to understand and modify the code to make more interesting instructables using the

Be the First to Share


    • Backyard Contest

      Backyard Contest
    • Silly Hats Speed Challenge

      Silly Hats Speed Challenge
    • Arduino Contest 2020

      Arduino Contest 2020

    2 Discussions


    4 years ago

    Thank you, exactly what I need.