0% found this document useful (0 votes)
3 views17 pages

Harhsita File

The document outlines a series of practical experiments related to the Internet of Things, focusing on the use of Arduino UNO and Tinkercad software. It includes objectives, required components, and sample codes for interfacing various sensors and components such as LEDs, push buttons, PIR sensors, temperature sensors, and ultrasonic sensors. Each experiment aims to familiarize students with basic electronics and programming concepts in a hands-on manner.
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)
3 views17 pages

Harhsita File

The document outlines a series of practical experiments related to the Internet of Things, focusing on the use of Arduino UNO and Tinkercad software. It includes objectives, required components, and sample codes for interfacing various sensors and components such as LEDs, push buttons, PIR sensors, temperature sensors, and ultrasonic sensors. Each experiment aims to familiarize students with basic electronics and programming concepts in a hands-on manner.
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/ 17

INTERNET OF THINGS

LAB PRACTICAL

2021 – 25

UNIVERSITY INSTITUTE OF ENGINEERING & TECHNOLOGY,

KURUKSHETRA UNIVERISTY, KURUKSHETRA

Submitted To: Submitted By:


Dr. Priyanka Jangra Harshita Dadheech
Faculty In-charge ECE A (4th Year)
Dept. Of Electronics & Communication 252101139
UIET, KUK

252101139
INDEX
S. No. Experiment No. Objective Page Remarks

1 Experiment 1 Familiarization with the concept of Arduino 03 - 06


UNO and Tinkercad software.

2 Experiment 2 To interface LED with Arduino and write a 07 – 08


program to turn ON/OFF LED.

3 Experiment 3 To interface Push Button with Arduino and 09 – 10


write a program to turn ON LED when push
button is pressed.

4 Experiment 4 To interface a PIR (Passive Infrared) sensor 11 – 12


with Arduino to detect motion.

5 Experiment 5 To interface a temperature sensor (e.g., LM35) 13 – 14


with Arduino and read temperature data.

6 Experiment 6 To interface an ultrasonic sensor (HC-SR04) 15 – 16


with Arduino to measure distance.

7 Experiment 7 To interface a 16x2 LCD display with Arduino 17


and display a message on the screen.

252101139
EXPERIMENT 01
Aim: Familiarization with the concept of Arduino UNO and Tinkercad software.

Objective: To study about Arduino and basic awareness about it and learnt use of Tinkercad.

Outcomes: Students will be able to understand Arduino, and learn to use Tinkercad, create simple electronic
circuits using electrical components and simulate the electronic circuit.

INTRODUCTION TO ARDUINO UNO

Arduino is an open-source electronics platform based on easy-to-use hardware and software. Arduino boards
are able to read inputs - light on a sensor, a finger on a button, or a Twitter message - and turn it into an output -
activating a motor, turning on an LED, publishing something online. You can tell your board what to do by
sending as of instructions to the microcontroller on the board. To do so you use the Arduino programming
language (based on Wiring), and the Arduino Software (IDE), based on Processing.

Arduino Uno is the most standard board available and probably the best choice for a beginner. We can directly
connect the board to the computer via a USB Cable which performs the function of supplying the power as well
as acting as a serial port.

Figure 1.1: Basic Arduino microcontroller Figure1.2: Cable for connection Arduino Uno

252101139
Figure1.3: Arduino Uno Pin details

• Vin: This is the input voltage pin of the Arduino board used to provide input supply from an external
power source.

• 5V: This pin of the Arduino board is used as a regulated power supply voltage and it is used to give
supply to the board as well as on board components.

• 3.3V: This pin of the board is used to provide a supply of 3.3V which is generated from a voltage
regulator on the board.

• GND: This pin of the board is used to ground the Arduino board.

• Reset: This pin of the board is used to reset the microcontroller. It is used to Resets the microcontroller.

• Analog Pins: The pins A0 to A5 are used as an analog input and it is in the range of 0-5V.

• Digital Pins: The pins 0to 13 are used as a digital input or output for the Arduino board.

• Serial Pins: These pins are also known as a UART pin. It is used for communication between the
Arduino board and a computer or other devices. The transmitter pin number1 and receiver pin number 0
is used to transmit and receive the data resp.

• External Interrupt Pins: This pin of the Arduino board is used to produce the External interrupt and it is
done by pin numbers 2 and 3.

• PWM Pins: These pins of the board is used to convert the digital signal into an analog by varying the
width of the Pulse. The pin numbers 3, 5, 6,9,10 and 11 are used as a PWM pin.

• SPI Pins: This is the Serial Peripheral Interface pin, it is used to maintain SPI communication with the
help of the SPI library.
252101139
• SPI pins include:
o SS: Pin number 10is used as a Slave Select
o MOSI: Pin number 11 is used as a Master Out, Slave In
o MISO: Pin number 12 is used as a Master In, Slave Out
o SCK: Pin number13 is used as a Serial Clock

• LED Pin: The board has an in built LED using digital pin-13. The LED glows only when the digital pin
becomes high.

• A REF Pin: This is an analog reference pin of the Arduino board. It is used to provide a reference
voltage from an external power supply.

INTRODUCTION TO TINKERCAD SOFTWARE

Tinkercad is a popular 3D modelling, circuitry-simulating, and block-coding software package that’s accessible
for free via a web browser. Its popularity is, no doubt, a rest of its user-friendly simplicity. It consists of three
sections, each of which can be considered its own endeavour and be used for different purposes.

Electronic Circuits with Tinkercad: An electronic circuit consists of a variety of electronic components such
as LED’s, switches, resistors and a power source. Tinkercad is a free online service for creating 3D shapes and
developing digital prototypes of electronic components. The digital prototype includes basic circuits with LED
lights, battery, switches, buzzers, etc.

Workspace: It is an area where the electronic components and 3D objects are placed.

Components of a circuit: Tinkercad displays the electronic components used to create circuits in the panel
usually at the right side of the page.

Some of the electronic components used to create circuits are:

• Basic components: It consists of a battery, push button, resistor, LED, capacitor, etc.

• Circuit Assembly: Circuit assemblies are simple, pre‐made circuits that can be in corporate into the 3D
designs. Some of the circuit assemblies available are glow circuit, move circuit and spin circuit.

• Rotate: It is used to rotate by 360 degrees any component placed on to the work space.

• VCC pin: Supplies power to the motor. Voltage anywhere between 5 to 35V can be applied. Remember,
if the 5V-EN jumper is in place, you need to supply 2 extra volts than the motor’s actual voltage
requirement, in order to run the motor at its maximum speed.

• GND is the common ground pin.

• 5V pin supplies power to the switching logic circuitry inside the L298N IC. If the 5V-EN jumper is in
place, this pin acts as output and can be used to power up the Arduino. If the 5V-EN jumper is removed,
you need to connect it to the 5V pin on Arduino.

• ENA pins are utilized to control the speed of Motor A. Supplying this pin with HIGH logic makes the
Motor A rotates, supplying it with LOW logic causes the motor to stop. Removing the jumper and
connecting this pin to the PWM input let us control the speed of the Motor A.

252101139
• IN1 & IN2 pins are used to control the direction of Motor A. If IN1 is HIGH and IN2 is LOW, Motor A
spins in a certain direction. To change the direction, make IN1 LOW and IN2 HIGH. If both the inputs
are either HIGH or LOW, the Motor A stops.

• IN3&IN4 pins are used to control the direction of the Motor B. If IN3 is HIGH and IN4 is LOW, Motor
B spins in a certain direction. To change the direction, make IN3 LOW and IN4 HIGH. If both the
inputs are either HIGH or LOW, the Motor B stops.

• ENB pin can be used to control the speed of Motor B. Supplying this pin with the HIGH signal makes
the Motor B turn, supplying it LOW cause the motor to stop. Eliminating the jumper and interfacing this
pin to PWM information let us control the speed of Motor B.

• OUT1 & OUT2 pins are connected to Motor A.

• OUT3 & OUT4 pins are connected to Motor B.

252101139
EXPERIMENT 02
Objective: To interface LED with Arduino and write a program to turn ON/OFF LED.

Software Used: Tinkercad

Components Required: Arduino UNO, Resistor, LED, Connecting wires

Theory: LED stands for Light Emitting Diode. It is a semiconductor device that emits light when an electric
current is passed through it. LEDs are commonly used in various applications, such as electronic displays,
lighting, and indicators. LEDs have several advantages over traditional light sources, such as incandescent bulbs
and fluorescent lamps, including lower energy consumption, longer lifespan, and smaller size. LEDs can emit
light in different colours, depending on the material used in the semiconductor. LED technology has advanced
rapidly in recent years, and LEDs are now widely used in many products, including smart phones, TV and
automobiles.

Code:
void setup(){
pinMode(13, OUTPUT);
}
void loop(){
digitalWrite(13, HIGH);
delay(1000); //Wait for 1000 millisecond(s)
digital Write(13, LOW);
delay(1000); //Wait for 1000 millisecond(s)
}

Block Code:

252101139
Output: LED starts to glow

252101139
EXPERIMENT 03
Objective: To interface Push Button with Arduino and write a program to turn ON LED when push button is
pressed.

Software Used: Tinkercad

Components Required: Arduino UNO, LED, Resistor, Push Button, Connecting Wires.

Theory: A Push Button is a type of switch work on a simple mechanism called “Push-to-make”.Initially,it
remains in off state or normally open state but when it is pressed, it allows the current to pass through it or we
can say it makes the circuit when pressed.Push Button structure has four legs, two on one side and other two on
another side. So, we can operate two lines of the circuit by single Push Button.

Code:
int button = 0;

void setup(){
pinMode(6, INPUT);
pinMode(13,OUTPUT);
Serial.begin(9600);
}

void loop(){
button = digitalRead(6);
Serial.println(button);

if (button == 1){
digitalWrite(13, HIGH);
} else{
digitalWrite(13, LOW);
}

delay(10); //Delay a little bit to improve simulation performance


}

252101139
Block Code:

Output: LED is glowing with help of push button.

252101139
EXPERIMENT 04
Objective: To interface a PIR (Passive Infrared) sensor with Arduino to detect motion.

Software Used: Tinkercad

Components Required: ArduinoUNO, PIR sensor, jumper wires,USB cable.

Theory: A PIR sensor detects infrared (IR) radiation emitted by objects, especially humans and animals. It
works by sensing changes in infrared levels when a warm object moves in or out of the sensor’s range. The
sensor has two IR-sensitive slots and a Fresnel lens to focus IR radiation.

When motion is detected, the output pin of the PIR sensor goes HIGH (3.3V or 5V). Arduino reads this digital
signal and can trigger actions such as turning on a light or sounding an alarm. PIR sensors are commonly used
in security systems, automatic lighting, and motion tracking.

Code:
const int PIR_SENSOR_OUTPUT_PIN = 4; // PIR sensor output pin
int warm_up = 0; // Initialize warm-up flag

void setup() {
pinMode(PIR_SENSOR_OUTPUT_PIN, INPUT);
Serial.begin(9600); // Define baud rate for serial communication

delay(20000); // Power On Warm Up Delay


}

void loop(){
int sensor_output = digitalRead(PIR_SENSOR_OUTPUT_PIN);

if(sensor_output == LOW) {
if(warm_up == 1) {
Serial.println("Warming Up");
warm_up = 0;
delay(2000);
}
Serial.println("No object in sight");
delay(1000);
} else {
Serial.println("Object detected");
warm_up = 1;
delay(1000);
}
}

252101139
Output:

252101139
EXPERIMENT 05
Objective: To interface a temperature sensor (e.g., LM35) with Arduino and read temperature data.

Software Used: Tinkercad

Components Required: Arduino UNO, LM35 Temperature Sensor, Jumper Wires, USB Cable.

Theory: The LM35 is a precision integrated-circuit temperature sensor whose output voltage is linearly
proportional to the Celsius (Centigrade) temperature. It provides an analog voltage output of 10 mV per degree
Celsius. For example, at 25°C, the output voltage is 250 mV. It operates over a temperature range of -55°C to
+150°C.

The Arduino Uno has a 10-bit ADC (Analog-to-Digital Converter), which converts the analog voltage (0– 5V)
into digital values ranging from 0 to 1023. By reading the analog pin connected to the LM35 output.

The Arduino processes this data and can display the temperature on the serial monitor, LCD, or send it for
further processing. This setup is useful in many embedded systems, IoT applications, and temperature-based
monitoring systems.

Code:
const int sensorPin = A0; // Analog input pin

void setup() {
Serial.begin(9600); // Initialize serial communication at 9600 baud
}

void loop() {

// Read the analog value from the sensor


int sensorValue = analogRead(sensorPin);

// Convert analog value to voltage (in volts)


float voltage = sensorValue * (5.0 / 1023.0); // 5V reference, 10-bit ADC

// Convert voltage to temperature (LM35 outputs 10mV per °C)


float temperatureCelsius = voltage * 100.0; // e.g., 0.25V * 100 = 25°C

// Print the temperature to the serial monitor


Serial.print("Temperature: ");
Serial.print(temperatureCelsius);
Serial.println(" °C");

delay(1000); // Wait for 1 second before taking the next reading


}

252101139
Output:

252101139
EXPERIMENT 06
Objective: To interface an ultrasonic sensor (HC-SR04) with Arduino to measure distance.

Software Used: Tinkercad

Components Required: Arduino UNO, Ultrasonic Sensor, jumper wires, USB cable.

Theory: The HC-SR04 ultrasonic sensor measures distance using ultrasonic sound waves. It has two main
components: Trigger and Echo. When a high pulse is sent to the Trigger pin, the sensor emits an 8-cycle
ultrasonic burst. If this burst hits an object, it reflects back and is received by the Echo pin.

The time taken between sending and receiving the signal is measured by Arduino. Using the speed of sound
(343 m/s).

The division by 2 accounts for the round-trip of the signal. This sensor is widely used in obstacle detection,
robotics, and distance measurement applications.

Code:
const int TRIG_PIN = 7;
const int ECHO_PIN = 6;

void setup() {
Serial.begin(9600);
pinMode(TRIG_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);
}

void loop() {
long duration;
float distance;

// Ensure trigger pin is low before starting


digitalWrite(TRIG_PIN, LOW);
delayMicroseconds(2);

// Send a 10-microsecond pulse to trigger


digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);

// Read the echo pin duration (time in microseconds)


duration = pulseIn(ECHO_PIN, HIGH);

// Calculate distance (duration / 2) * speed of sound (34300 cm/s)


distance = (duration * 0.0343) / 2;

// Display the distance on the Serial Monitor


Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");

delay(500); // Delay to prevent overwhelming the serial monitor


}

252101139
Output:

252101139
EXPERIMENT 07
Objective: To interface a 16x2 LCD display with Arduino and display a message on the screen.
Software Used: Tinkercad
Components Required: Arduino UNO, 16*2 LCD display, potentiometer, resistor, jumper wires, USB
Cable.
Theory: An LCD (Liquid Crystal Display) is a flat-panel display technology commonly used in electronic
devices. The 16x2 LCD has 2 rows and 16 columns, capable of displaying 32 characters. It operates in two
modes: 4-bit and 8-bit. In 4-bit mode, only 4 data lines are used to send data, which saves I/O pins on the
Arduino.
The display has control pins like RS (Register Select), E (Enable), and data pins D0–D7. The LiquidCrystal
library in Arduino provides built-in functions to initialize the LCD, set cursor position, and print text. A 10k
potentiometer is typically used to adjust the display contrast. The LCD requires proper initialization and
timing for correct display of data.
Code:
#include<LiquidCrystal.h>

const int rs = 13, en = 12, d4 = 4, d5 = 5, d6 = 6,d7 = 7;


LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup(){
lcd.begin(16,2);
lcd.print("ONE PIECE");
}

void loop(){
for (int positionCounter = 1; positionCounter++;) {
lcd.scrollDisplayLeft();
delay(100);
}
delay(500);
}

Output:

252101139

You might also like