SRI GURU TEGH BAHADUR INSTITUTE OF
MANAGEMENT AND INFORMATION
TECHNOLOGY
(AFFILIATED TO GURU GOBIND SINGH INDRAPRASTHA UNIVERSITY)
BACHELOR OF COMPUTER APPLICATION
SESSION: 2021-2024
INTERNET OF THINGS PRACTICAL FILE
SUBMITTED TO: SUBMITTED BY:
MS. NEHU GUMBER ABHIJEET SINGH
ASSISTANT PROFESSOR ROLL NO. 36290202021
BCA 6 B
INDEX
S. NO. TOPIC SIGN
1. Study and Install IDE of Arduino
2. Write the steps to add libraries in Arduino and setup
of Arduino IDE for programming.
3. Write code and show implementation of Arduino
Uno for LED blink.
4. Write code and show implementation of Arduino
Uno for checking temperature.
5. Write a program to shows how to fade an LED on
pin 9 using the analog Write( )function
6. Write a program to show the implementation of
ultrasonic sensor.
7. Write steps to add blynk libraries for node mcu and
account on IFTTT for home automation.
8. Write a program for Arduino by using Ultrasonic
sensors and servo motor.
CODE 1
Study and Install IDE for Arduino
CODE
STUDY ABOUT ARDUINO IDE
(INTEGRATED DEVELOPMENT ENVIRONMENT)
INTRODUCTION:
Arduino is an open-source electronics platform based on easy-to-use hardware
and software. It consists of a programmable circuit board often referred to as a
microcontroller and a development environment for writing, testing, and
uploading code to the board.
The new major release of the Arduino IDE is faster and even more powerful! In
addition to a more modern editor and a more responsive interface it features
autocompletion, code navigation, and even a live debugger.
FEATURES OF ARDUINO
Microcontroller Board:
The heart of the Arduino platform is its microcontroller board. The most
commonly used microcontroller in Arduino boards is the Atmel AVR series,
though some newer boards use ARM-based microcontrollers.
Development Environment (IDE):
Arduino provides an Integrated Development Environment (IDE) for writing
code. The IDE is based on the Processing programming language and includes a
code editor, compiler, and uploader.
Arduino Language:
The programming language used with Arduino is a simplified version of
C/C++ with some specific libraries and functions provided by the Arduino
software.
DOWNLOADING OF ARDUINO
Go to google chrome or any other web browser like Microsoft Edge
Search Arduino in search bar it will take you to the mentioned link
https://www.arduino.cc/en/software
After scrolling down, you see the image shown below
If you are using windows 10 or 11 then click on first option that is
Windows Win 10 and newer, 64 bits
After clicking you will see the image shown below
Click on “JUST DOWNLOAD” option
After clicking on “JUST DOWNLOAD” a message at top left of screen
will appear as
This message means that ARDUINO for your operating system is
downloaded
After this Go to “Downloads” option in your system and there you will
see the arduino-ide
INSTALLATION OF ARDUINO
Click on Arduino-ide in downloads, a message box will appear as shown
below
Click on “Run” command, a setup page with terms and conditions will
appear shown in image below
Click on “I Agree” option, a message box will appear again
In this message box you will select Only me option
After this a message box displays you the location path where you want
to install the Arduino software, here you can select the path by yourself
where you want to install it.
After selecting the path Click on “Install” option
After clicking you will see the beginning of installation process
As the installation process ends an image shown below displays
“Completing Arduino IDE Setup”
After clicking on “Finish” option the Arduino screen will appear as the
image displaying the result below
CODE 2
Write the steps to add libraries in Arduino and setup of Arduino IDE for
programming.
CODE
STEPS FOR ADDING LIBRARY TO ARDIUNO UNO
Open the Arduino application
Click on “Sketch” option from the top
Now from “Sketch” option choose “Include Library” option
Now, select “Manage Library” option and it will display a Library
Manager from where you can install desired library
In search option of Library Manager enter name of library you want to
install
SETUP FOR ARDIUNO IDE FOR PROGRAMMING
Open the Arduino application and tap on “Select Board” option
After selecting on “Select Board” option from the top the options will
appear as select other board and ports
After choosing “Select other boards and ports” a new window with search
bar will appear
Choose “Arduino UNO” and click on OK button you see the board is
selected
CODE 3
Write code and show implementation of Arduino Uno for LED blink.
CONNECTION OF SENSOR WITH ARDIUNO UNO AND BREAD
BOARD
STEPS FOR ARDIUNO UNO BOARD, HEADER PINS, BREAD BOARD
AND SENSOR
1. Gather the equipment’s required for performing the task like Ardiuno
Uno Board, Bread Board, Blub and 2 header pins.
2. Connect Ardiuno Uno Board to system using USB cable.
3. Connect the header pins with Ardiuno Uno Board and Bread Board
4. 7 and 8 are the recommended input slots of Ardiuno Uno Board you can
use as preference of task
5. Connecting 1st header pin that is positive side to ground of Ardiuno Uno
Board displayed as GNR on Board.
6. Connecting 2nd header pin that is negative side to 7 for input.
7. Connect Bulb with Bread Board
8. Connect other side of 1st header pin that is negative side with Bread
Board
9. Connect other side of 2nd header pin that is positive side with to Bread
Board
10. Define input button as selected input slot as here 7 is selected so input
button is taken 7 in Ardiuno Uno software before running the code
CIRCUIT DIAGRAM FOR BLINK LED
ARDUINO UNO
0
1
2
3
4
5
6
7
1 2
8
GND
2
LED ARDIUNO BREAD Header
UNO BOARD Pins
BOARD
Longest Positive side
side
Shortest Negative
side side
D7 Negative
side
GNR Positive
side
CODE
int led1=7;
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(7, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(led1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the
voltage LOW
delay(1000); // wait for a second
}
The output will occur as the light on as shown below
OUTPUT
CODE 4
Write code and show implementation of Arduino Uno for checking
temperature.
CONNECTION OF SENSOR WITH ARDIUNO UNO AND BREAD
BOARD
STEPS FOR ARDIUNO UNO BOARD, HEADER PINS, BREAD BOARD
AND SENSOR
1. Gather the equipment’s required for performing the task like Ardiuno
Uno Board, Bread Board, Temperature measuring Sensor and 3 header
pins.
2. Connect Ardiuno Uno Board to system using USB cable.
3. Connect the header pins with Ardiuno Uno Board and Bread Board
4. 7 and 8 are the recommended input slots of Ardiuno Uno Board you can
use as preference of task
5. Connecting 1st header pin that is positive side to ground of Ardiuno Uno
Board displayed as GNR on Board.
6. Connecting 2nd header pin that is negative side to A0 for input.
7. Connecting 3rd header pin to 5V for power.
8. Connect Sensor with Bread Board
9. Connect other side of 1st header pin that is negative side with respect to
ground of sensor displayed as GNR
10. Connect other side of 2nd header pin that is positive side with respect to
vcc slot of sensor
11. Connect other side of 3rd header pin with respect to data/signal slot of
sensor
12. Add DHT library to Ardiuno Uno software before running the code
CIRCUIT DAIGRAM FOR TEMPERATURE CHECKING
3V3 5V Vin
Power D13
RST D12
AREF D11
IO REF D10
N/C D9
D8
D7
D6
D5
A0 D4
A1 D3
A2 D2
Vout
A3 D1
Temp Sensor A4 D0
+vcc A5 SCL
SDA
GNR
GNR
SENSOR ARDUINO BREAD HEADER PINS
UNO BOARD BOARD
GNR GNR Negative side Pin 1
Vout 5V Positive side Pin 2
VCC A0 Negative side Pin 3
CODE
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include<DHT_U.h>
#define DHT_PIN 7
DHT dht(7, DHT11);
void setup() {
Serial.begin(9600);
dht.begin();
}
void loop() {
// put your main code here, to run repeatedly:
float temp = dht.readTemperature();
float humidity = dht.readHumidity();
Serial.print("Temp : ");
Serial.print(temp);
Serial.println("C");
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.println("%");
delay(1000);
}
SENSOR
After all the connection and code compilation serial monitor display the output
shown below
OUTPUT
CODE 5
Write a program to shows how to fade an LED on pin 9 using the analog
Write( )function.
CONNECTION OF SENSOR WITH ARDIUNO UNO AND BREAD
BOARD
STEPS FOR ARDIUNO UNO BOARD, HEADER PINS, BREAD BOARD
AND SENSOR
1. Gather the equipment’s required for performing the task like Ardiuno
Uno Board, Bread Board, Blub and 2 header pins.
2. Connect Ardiuno Uno Board to system using USB cable.
3. Connect the header pins with Ardiuno Uno Board and Bread Board
4. Select 9 analog board point as mentioned in task
5. Connecting 1st header pin that is positive side to ground of Ardiuno Uno
Board displayed as GNR on Board.
6. Connecting 2nd header pin that is negative side to 9 for input.
7. Connect Bulb with Bread Board
8. Connect other side of 1st header pin that is negative side with Bread
Board
9. Connect other side of 2nd header pin that is positive side with to Bread
Board
10. Define input button as selected input slot as here 7 is selected so input
button is taken 9 in Ardiuno Uno software before running the code
CIRCUIT DIAGRAM FOR BLINK LED
ARDUINO UNO
0
1
2
3
4
5
6
7
1 2
8
9
1
GND 2
LED ARDIUNO BREAD Header
UNO BOARD Pins
BOARD
Longest Positive side
side
Shortest Negative
side side
A9 Negative
side
GNR Positive
side
CODE
int led1=9;
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(9, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
analogWrite(led1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
analogWrite(LED_BUILTIN, LOW); // turn the LED off by making the
voltage LOW
delay(1000); // wait for a second
}
The output will occur as the light on as shown below
OUTPUT
CODE 6
Write a program to show the implementation of ultrasonic sensor.
CONNECTION OF SENSOR WITH ARDIUNO UNO AND BREAD
BOARD
STEPS FOR ARDIUNO UNO BOARD, HEADER PINS, BREAD BOARD
AND SENSOR
1. Gather the required equipment to perform the task like Ultrasonic sensor,
Bread Board, Arduino Uno Board and Header pins.
2. Connect the Arduino Uno Board with system.
3. Connect Ultrasonic sensor to Bread Board.
4. Connect 1st header pin with ground of sensor and other side with ground
of Arduino Uno Board.
5. Connect 2nd header pin adjacent to VCC of Ultrasonic sensor and other
side to 5V of Arduino Uno Board for power supply.
6. Connect 3rd header pin with Trigger of Ultrasonic sensor and other side to
D8 for input.
7. Connect 4th header pin with Echo of Ultrasonic sensor and other side to
D9 for representing output on serial pointer.
CIRCUIT DIAGRAM
CIRCUIT DAIGRAM FOR TEMPERATURE CHECKING
3V3 5V Vin
Power D13
RST D12
AREF D11
IO REF D10
N/C D9
D8
D7
D6
D5
A0 D4
A1 D3
A2 D2
A3 D1
A4 D0 Temp Sensor
A5 SCL
SDA
VCC Trig Echo GNR
GNR
SENSOR ARDUINO BREAD HEADER PINS
UNO BOARD BOARD
GNR GNR Negative side Yellow
VCC 5V Positive side Orange
Trigger D8 Red
Echo D9 Voilet
SENSOR
CODE
// Define pin connections
const int trigPin = 8; // Trigger pin of ultrasonic sensor
const int echoPin = 9; // Echo pin of ultrasonic sensor
// Variables for duration and distance
long duration;
int distance;
void setup() {
// Initialize serial communication
Serial.begin(9600);
// Define pin modes
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
void loop() {
// Clear the trigger pin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Send a pulse to trigger the ultrasonic sensor
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Measure the duration of the pulse on the echo pin
duration = pulseIn(echoPin, HIGH);
// Calculate the distance based on the speed of sound
distance = duration * 0.034 / 2;
// Print the distance to the serial monitor
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
// Wait a short delay before taking the next measurement
delay(100);
OUTPUT
CODE 7
Write steps to add blynk libraries for nodemcu and account on ifttt for
home automation.
CODE
STEPS FOR ADDING BLYNK LIBRARY TO ARDIUNO UNO
Open the Arduino application
Click on “Sketch” option from the top
Now from “Sketch” option choose “Include Library” option
Now, select “Manage Library” option and it will display a Library
Manager from where you can install desired library
In search option of Library Manager enter Blynk and install the Library.
As you install blynk library
Go to file open examples and you see the blynk examples as shown
below
Steps for Creating Account on IFTTT
Go to the official website of IFTTT https://ifttt.com/
Click on first link it will proceed you to login and signup page of site
Here you can choose any of option continue, sign up or login if
account already exists.
Now if you select signup option it will appear as shown below
After processing further like selecting options or signup it will appear
the display
It shows that the account is created for using IFTTT.
CODE 8
Write a program for Arduino by using Ultrasonic sensors and servo motor.
CONNECTION OF SENSOR WITH ARDIUNO UNO AND BREAD
BOARD
STEPS FOR ARDIUNO UNO BOARD, HEADER PINS, BREAD BOARD
AND SENSOR
1. Gather the required equipment to perform the task like Ultrasonic sensor,
Servo Motor Sensor, Bread Board, Arduino Uno Board and Header pins.
2. Connect the Arduino Uno Board with system.
3. Connect Ultrasonic sensor to Bread Board.
4. Connect 1st header pin with ground of sensor and other side with ground
of Arduino Uno Board.
5. Connect 2nd header pin adjacent to VCC of Ultrasonic sensor and other
side to 5V of Arduino Uno Board for power supply.
6. Connect 3rd header pin with Trigger of Ultrasonic sensor and other side to
D8 for input.
7. Connect 4th header pin with Echo of Ultrasonic sensor and other side to
D9 for representing output on serial pointer.
8. Connect the 1st header pin of Servo Motor that is Orange with D7 slot of
Arduino Uno Board.
9. Connect the 2nd header pin of Servo Motor Sensor that is Red with 5V for
power supply.
10. Connect the 3rd header pin of Servo Motor Sensor that is Brown with
GNR of Arduino Uno Board.
CIRCUIT DIAGRAM
CIRCUIT DAIGRAM FOR TEMPERATURE CHECKING
3V3 5V Vin
Power D13 Servo Motor Sensor
RST D12
AREF D11
IO REF D10
N/C D9
D8
D7
D6
D5
A0 D4
A1 D3
A2 D2
A3 D1
A4 D0 Temp Sensor
A5 SCL
SDA
VCC Trig Echo GNR
GNR
ULTRA SONIC ARDUINO BREAD HEADER PINS
SENSOR UNO BOARD BOARD
GNR GNR Negative side Yellow
VCC 5V Positive side Orange
Trigger D8 Red
Echo D9 Voilet
SERVO MOTOR
SENSOR
Orange D7 Orange
Red 5V Positive side Red
Brown GNR Negative side Brown
SENSOR
ULTRA SONIC SENSOR
SERVO MOTOR SENSOR
CODE
#include <Servo.h>
Servo servo1;
int trigPin = 9;
int echoPin = 8;
long distance;
long duration;
void setup()
{
servo1.attach(7);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);// put your setup code here, to run once:
}
void loop()
{
ultra_sonic();
servo1.write(60);
if(distance <=60)
{
servo1.write(360);
}}
void ultra_sonic()
{
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration*0.034/2;
}
OUTPUT
The Servo Motor Sensor runs the device connected to Servo Motor
Sensor