0% found this document useful (0 votes)
13 views5 pages

Worksheet - 2 IOT Khu

The document outlines a practical assignment for interfacing an Arduino Uno with an Ultrasonic Sensor and an LCD to measure and display distance. It includes the aim, hardware and software requirements, circuit connections, coding instructions, and learning outcomes related to the project. Additionally, it provides an evaluation grid for assessing the worksheet, viva, and simulation components of the assignment.

Uploaded by

khushi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views5 pages

Worksheet - 2 IOT Khu

The document outlines a practical assignment for interfacing an Arduino Uno with an Ultrasonic Sensor and an LCD to measure and display distance. It includes the aim, hardware and software requirements, circuit connections, coding instructions, and learning outcomes related to the project. Additionally, it provides an evaluation grid for assessing the worksheet, viva, and simulation components of the assignment.

Uploaded by

khushi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Worksheet No.

: 2

Student Name : Khushi Mittaliya UID : 23MCI10221


Branch : MCA(AIML) Section/Group : 23MAM-3/B
Semester : 4th Date of Performance : 28/01/2025
Subject Name : Internet of Things Subject Code : 23CAH-702

1. Aim of the practical:


Interface an Arduino Uno with an Ultrasonic Sensor to measure the distance and display the results
on both a Serial Monitor and an LCD. Implement the specified cases based on the calculated
distance.

Implement the following cases in your Arduino Code:

Case 1: If the distance less than 20 cm, display “Too Close” on the LCD.

Case 2: If the distance is between 20 cm and 50 cm, display “Safe Distance” on the LCD.

Case 3: If the distance is greater than 50 cm, display “Far Away” on the LCD.

2. Hardware and Software Requirements:


a) Arduino Uno
b) Ultrasonic Sensor
c) 16x2 LCD Display

3. Steps to perform and Circuit diagram:

Ultrasonic Sensor:
• VCC → 5V on Arduino.
• GND → GND on Arduino.
• Trig → Digital Pin 9 on Arduino.
• Echo → Digital Pin 8 on Arduino.

LCD (I2C):
• VCC → 5V on Arduino.
• GND → GND on Arduino.
• SDA → A4 on Arduino.
• SCL → A5 on Arduino.

Case 1: If the distance less than 20 cm, display “Too Close” on the LCD.
Case 2: If the distance is between 20 cm and 50 cm, Case 3: If the distance is greater than 50 cm,
display “Safe Distance” on the LCD. display “Far Away” on the LCD.

4. Coding :
// C++ code
#include <LiquidCrystal_I2C.h>
// Initialize the I2C LCD (Address 0x27 and 16x2 display)
LiquidCrystal_I2C lcd(0x27, 16, 2);
// Ultrasonic Sensor Pins
const int trigPin = 9;
const int echoPin = 10;
void setup() {
// Initialize LCD and Serial Monitor
lcd.init();
lcd.backlight();
Serial.begin(9600);
// Set Ultrasonic Sensor Pins
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
lcd.print("Distance Test");
delay(2000);
lcd.clear(); }
void loop() {
// Send Trigger Pulse
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Read Echo Pulse
long duration = pulseIn(echoPin, HIGH);
// CalcuLate Distance (cm) or handle timeout
float distance;
if (duration == 0) {
distance = -1; // Error value
} else {
distance = (duration * 0.0343) / 2; }
Serial.print("Distance: ");
if (distance == -1) {
Serial.println("Error: No signal");
} else {
Serial.print(distance);
Serial.println(" cm"); }
// Display on LCD
lcd.setCursor(0, 0); // First row
if (distance == -1) {
lcd.print("Error: No signal ");
} else {
lcd.print("Dist: ");
lcd.print(distance);
lcd.print(" cm "); }
lcd.setCursor(0, 1); // Second row
if (distance == -1) {
lcd.print("Check sensor ");
} else if (distance < 20.0) {
lcd.print("Too Close ");
} else if (distance >= 20.0 && distance <= 50.0) {
lcd.print("Safe Distance");
} else {
lcd.print("Far Away "); }
delay(500); // Delay for stability }

5. Learning outcomes (What I have learnt):


a) Learn to interface an ultrasonic sensor and an I2C LCD with Arduino Uno.
b) Gain experience using Arduino libraries (Wire and LiquidCrystal_I2C).
c) Understand ultrasonic sensor principles for distance measurement.
d) Develop conditional logic based on real-time sensor data.
e) Utilize the Serial Monitor for debugging and validation.
f) Create a functional prototype for robotics or IoT applications.

Evaluation Grid (To be created as per the SOP and Assessment guidelines by the faculty):

Sr. No. Parameters Marks Obtained Maximum Marks


1. Worksheet 8 Marks
2. Viva 10 Marks
3. Simulation 12 Marks
Total 30 Marks

Teacher Signature

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy