Sonar Range Finder by Sam and Ryu

This is an instructable for making a sonar range finder that lights up an LED when a laptop is partially closed (using arduino Uno).

Step 1: Make Circuit Using Arduino


Jumper cables X 8

Sonar range finder X 1


220 Ohm resistor X 1

arduino breadboard X 1

arduino uno X 1


Sonar range finder (SRF) VCC to 5v on arduino, SRF Trig to digital 9 pin on arduino, SRF Echo to digital 10 pin on arduino, SRF GND to (-) line on the breadboard, the same (-) line to a numbered line (ex. line 1) on the breadboard (using a jumper cable), the same numbered line to another numbered line (ex. line 2) on the breadboard (using the 220 Ohm resistor), the recent numbered line (line 2) to another numbered line (ex. line 3) on the breadboard (using the LED), the recent numbered line (line 3) to digital pin 11 on the arduino (using a jumper cable), and lastly the (-) line to a GND pin on the arduino (using a jumper cable).

Step 2: The Program

Using the arduino software, upload the following code on to the arduino:

void setup() {
// put your setup code here, to run once:

pinMode(9, OUTPUT);

pinMode(10, INPUT);

pinMode(11, OUTPUT);

Serial.begin(9600); }

void loop() {

// put your main code here, to run repeatedly:

digitalWrite(9, LOW);


digitalWrite(9, HIGH);


digitalWrite(9, LOW);

float duration = pulseIn(10,HIGH);


if(duration < 300){

digitalWrite(11, HIGH);



digitalWrite(11, LOW);




Step 3: Enjoy the Sonar Range Sensor Which Tells You When a Laptop Is Partially Closed

Put the sensor on the laptop and and enjoy the LED light up when the laptop lid is close top the sensor (but not literally on the sensor). The values picked up by the sensor can be observed using the magnifying glass button on the top right of the arduino software.

Step 4: Testing the Sensor

You can test the sensor by using a flat object and a ruler. The values picked up by the sensor should correlate to distance with the equation: value = 55(distance) + 43.333 (or something similar), the distance being in centimeters. The LED should light up when the value picked is less than 300, so the equivalent distance should be about 4.67cm after solving for 300 = 55(x) + 43.33.

You can form your own equation by entering 3 ordered pairs into a graphing calculator (3 different distances in cm as X values, and their associated values picked up by the sensor as Y values), and using the linear regression tool.



    • Remix Contest

      Remix Contest
    • Organization Contest

      Organization Contest
    • Faux-Real Contest

      Faux-Real Contest



    Welcome to Instructables. Thanks for sharing with the communtiy.