You are on page 1of 4

Laboratory Activity No.

Linear Displacement Measuring Instrument

Name: ___________________________ Rating: ________________


Section: __________________________ Date: __________________

Objectives:

This experiment will enable the student


1. To measure linear displacement using the ultrasonic sensor.
2. To interface an ultrasonic sensor, LCD display and Arduino the process
3. To create an angular displacement measuring instrument

Equipment and Materials:

Qty Equipment/Materials
1 Personal Computer
1 Arduino microcontroller
1 LCD Display
1 Ultrasonic sensor
1 USB cable
1 Potentiometer
1 Power supply
1 Breadboard
1 set Connecting wires

Introduction:

In this activity we will going to create a linear displacement measuring device or


instrument. The instrument is compose of the ultrasonic sensor, the LCD as the indicator or
display and the Arduino microcontroller as the processor.
We will use the ultrasonic sensor to measure the distance of the object in front of it.
The sensor will release an ultrasonic sound to its transmitter that will hit the object in front.
The sound will reflect back to the sensor and will received by the receiver part. The sensor
will record the time it takes for the sound to return. Considering the speed of sound as
constant, the time will be used to compute the distance travelled by the sound and also the
basis as the distance of the object to the sensor. All computation will be handled by the build
in library for ultrasonic in the Arduino program.
The liquid crystal display (LCD) provides the display to indicate the amount of linear
distance does the ultrasonic sensor acquired. To display the information received by the
Arduino from the potentiometer a build in library in Arduino programming will be used to
control the output display.
Procedures:
A. Set-up
1. Connect the computer and Arduino microcontroller using USB serial cable

2. Connect the ultrasonic sensor to the microcontroller as shown below.

3. Then connect the LCD display to the microcontroller as shown below.


B. Arduino Program:
1. Write the program below to the microcontroller. (Note include to folder library of
NewPing to the Arduino library it contains the need instruction to compute the
distance of the object).

#include <NewPing.h>
#define TRIGGER_PIN 10
#define ECHO_PIN 9
#define MAX_DISTANCE 100
double dist;
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);

#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
lcd.begin(16, 2);
lcd.print("Distance (cm):");
}

void loop() {
dist=sonar.ping_cm();
lcd.setCursor(0, 1);
lcd.print(dist);
delay(200);
}

Data:
1. Explain line by line what does the code do?
____________________________________________________________________
____________________________________________________________________
____________________________________________________________________
____________________________________________________________________
____________________________________________________________________
____________________________________________________________________
____________________________________________________________________
____________________________________________________________________

2. Face the ultrasonic sensor to the place of free of obstruction. What is the reading in
the LCD display?
____________________________________________________________________
____________________________________________________________________
3. Put any object in front (very close to the transmitter part) of the sensor. What is the
reading in the LCD display?
____________________________________________________________________
____________________________________________________________________

4. Slowly move the object away. Describe what is happening to LCD display reading?
____________________________________________________________________
____________________________________________________________________
____________________________________________________________________

5. Put a very small object in front. What is the reading in the LCD display? Why?
____________________________________________________________________
____________________________________________________________________
____________________________________________________________________

You might also like