Professional Documents
Culture Documents
Objectives:
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:
#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?
____________________________________________________________________
____________________________________________________________________
____________________________________________________________________