IOT Lab Manual
IOT Lab Manual
(VI SEMESTER)
Lab Manual
Branch: CE
6th Semester
Certificate
This is to Certify that Mr./Ms ..................................................................................................Of
Subject Head
In-charge Of Department
Approved By
Principal
Web Technology 2160708 Computer Engineering
INDEX
SR PAGE
CONTENT DATE MARKS SIGN.
NO. NO.
PRACTICAL: 1
Aim: Study and Install IDE of Arduino and different types of Arduino.
Introduction:
Arduino is an open-source prototyping platform in electronics based on easy-to-use hardware
and software. Subtly speaking, Arduino is a microcontroller based prototyping board which
can be used in developing digital devices that can read inputs like finger on a button, touch on
a screen, light on a sensor etc. and turning it in to output like switching on an LED, rotating a
motor, playing songs through a speaker etc.
Arduino UNO:
In this tutorial, we will be discussing the Arduino UNO board. Arduino UNO is a basic and
inexpensive Arduino board and is the most popular of all the Arduino boards with a market
share of over 50%. Arduino UNO is considered to be the best prototyping board for beginners
in electronics and coding.
UNO is based on ATmega328P microcontroller. There are two variants of the Arduino UNO:
one which consists of through – hole microcontroller connection and other with surface mount
type. Through-hole model will be beneficial as we can take the chip out in case of any problem
and swap in with a new one.
Arduino UNO comes with different features and capabilities. As mentioned earlier, the
microcontroller used in UNO is ATmega328P, which is an 8-bit microcontroller based on the
AVR architecture. UNO has 14 digital input – output (I/O) pins which can be used as either
input or output by connecting them with different external devices and components. Out of
these 14 pins, 6 pins are capable of producing PWM signal. All the digital pins operate at 5V
and can output a current of 20mA.
Page no.: 1
Shree Swaminarayan Institute of Technology CE/IT DEPT. (VI Semester)
(Fig: 1.1)
• Pins 0 and 1 are used for serial communication. They are used to receive and transmit serial
data which can be used in several ways like programming the Arduino board and
communicating with the user through serial monitor.
• Pins 2 and 3 are used for external interrupts. An external event can be triggered using these
pins by detecting low value, change in value or falling or rising edge on a signal.
• As mentioned earlier, 6 of the 14 digital I/O Pins i.e. 3, 5, 6, 9, 10, and 11 can provide 8-
bit PWM output.
• Pins 10, 11, 12 and 13 (SS, MOSI, MISO AND SCK respectively) are used for SPI
communication.
Page no.: 2
Shree Swaminarayan Institute of Technology CE/IT DEPT. (VI Semester)
• Pin 13 has a built-in LED connected to it. When the pin is HIGH, the LED is turned on and
when the pin is LOW, it is turned off.
• Arduino Uno has 6 analog input pins which can provide 10 bits of resolution i.e. 1024
different values. The analog pins on the Arduino UNO are labelled A0 to A5.
▪ Weighing Machines.
▪ Traffic Light Count Down Timer.
▪ Parking Lot Counter.
▪ Embedded systems.
▪ Home Automation.
▪ Industrial Automation.
▪ Medical Instrument.
▪ Emergency Light for Railway
Step 1 − First you must have your Arduino board (you can choose your favorite board) and a
USB cable. In case you use Arduino UNO, Arduino Duemilanove, Nano, Arduino Mega 2560,
or Diecimila, you will need a standard USB cable (A plug to B plug), the kind you would
connect to a USB printer as shown in the following image.
Page no.: 3
Shree Swaminarayan Institute of Technology CE/IT DEPT. (VI Semester)
In case you use Arduino Nano, you will need an A to Mini-B cable instead as shown in the
following image.
Page no.: 4
Shree Swaminarayan Institute of Technology CE/IT DEPT. (VI Semester)
plastic that fits onto two of the three pins between the USB and power jacks. Check that it
is on the two pins closest to the USB port.
Connect the Arduino board to your computer using the USB cable. The green power LED
(labeled PWR) should glow.
Page no.: 5
Shree Swaminarayan Institute of Technology CE/IT DEPT. (VI Semester)
Page no.: 6
Shree Swaminarayan Institute of Technology CE/IT DEPT. (VI Semester)
Here, we are selecting just one of the examples with the name Blink. It turns the LED on and
off with some time delay. You can select any other example from the list.
Here, we have selected Arduino Uno board according to our tutorial, but you must select the
name matching the board that you are using.
Page no.: 7
Shree Swaminarayan Institute of Technology CE/IT DEPT. (VI Semester)
Page no.: 8
Shree Swaminarayan Institute of Technology CE/IT DEPT. (VI Semester)
F − Serial monitor used to receive serial data from the board and send the serial data
to the board.
Now, simply click the "Upload" button in the environment. Wait a few seconds; you will see
the RX and TX LEDs on the board, flashing. If the upload is successful, the message "Done
uploading" will appear in the status bar.
Note − If you have an Arduino Mini, NG, or other board, you need to press the reset button
physically on the board, immediately before clicking the upload button on the Arduino
Software.
Page no.: 9
Shree Swaminarayan Institute of Technology CE/IT DEPT. (VI Semester)
PRACTICAL: 2
Aim: Write a Program for blink LED using Arduino.
Source Code:
void loop()
{
digitalWrite(ledPin, HIGH);
delay(200);
digitalWrite(ledPin, LOW);
delay(200);
}
Output:
Page no.: 10
Shree Swaminarayan Institute of Technology CE/IT DEPT. (VI Semester)
PRACTICAL: 3
Aim: Write a program for fade in LED using Arduino.
Source Code:
void loop()
{
for(int sig=0;sig<=255;sig+=1){
analogWrite(ledPin, sig);
delay(6);
}
for(int sig=255;sig>=0;sig-=1){
analogWrite(ledPin, sig);
delay(6);
}
}
Output:
Page no.: 11
Shree Swaminarayan Institute of Technology CE/IT DEPT. (VI Semester)
PRACTICAL: 4
Aim: Write a program for multiple LED blinking using Arduino.
Source Code:
void loop()
{
blinkAllLed();
}
void blinkAllLed(){
for(int i=0;i<6;i++){
digitalWrite(arrPin[i], HIGH);
Page no.: 12
Shree Swaminarayan Institute of Technology CE/IT DEPT. (VI Semester)
delay(d);
digitalWrite(arrPin[i], LOW);
delay(d);
}
}
Output:
Page no.: 13
Shree Swaminarayan Institute of Technology CE/IT DEPT. (VI Semester)
PRACTICAL: 5
Aim: Write a program for RGB LED blinking using Arduino.
Source Code:
void loop()
{
for(int i=0;i<3;i++){
digitalWrite(rgbPins[i], HIGH);
delay(300);
digitalWrite(rgbPins[i], LOW);
}
}
Output:
Page no.: 14
Shree Swaminarayan Institute of Technology CE/IT DEPT. (VI Semester)
PRACTICAL: 6
Aim: Write a Program for LED blink using Push Button.
Source Code:
Output:
Page no.: 15
Shree Swaminarayan Institute of Technology CE/IT DEPT. (VI Semester)
PRACTICAL: 7
Aim: Write program for demonstrating temperature sensor by using
Arduino.
Source Code:
float temp;
void setup(){
pinMode(A5,INPUT);
Serial.begin(9600);
}
void loop(){
temp=analogRead(A5);
temp=(temp*0.491)-50;
Serial.println(temp);
delay(1000);
}
Output:
Page no.: 16
Shree Swaminarayan Institute of Technology CE/IT DEPT. (VI Semester)
PRACTICAL: 8
Aim: Display message in 16*2 LCD display by using Arduino UNO.
Source Code:
#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("hello, world!");
}
void loop() {
}
Output:
Page no.: 17
Shree Swaminarayan Institute of Technology CE/IT DEPT. (VI Semester)
PRACTICAL: 9
Aim: Reads an analog input and prints the voltage to the Serial Monitor.
Source Code:
void setup()
{
Serial.begin(9600);
pinMode(A2,INPUT);
}
void loop()
{
int sensorVal = analogRead(A2);
float voltage = sensorVal * (5.0 / 1023.0);
Serial.println(voltage);
}
Output:
Page no.: 18
Shree Swaminarayan Institute of Technology CE/IT DEPT. (VI Semester)
PRACTICAL: 10
Aim: Study Raspberry Pi.
Raspberry Pi is popularly used for real time Image/Video Processing, IoT based applications
and Robotics applications.
Raspberry Pi is slower than laptop or desktop but is still a computer which can provide all the
expected features or abilities, at a low power consumption.
Raspberry Pi Foundation officially provides Debian based Raspbian OS. Also, they provide
NOOBS OS for Raspberry Pi. We can install several Third-Party versions of OS like Ubuntu,
Archlinux, RISC OS, Windows 10 IOT Core, etc.
Raspbian OS is official Operating System available for free to use. This OS is efficiently
optimized to use with Raspberry Pi. Raspbian have GUI which includes tools for Browsing,
Python programming, office, games, etc.
We should use SD card (minimum 8 GB recommended) to store the OS (Operating System).
Page no.: 19
Shree Swaminarayan Institute of Technology CE/IT DEPT. (VI Semester)
Raspberry Pi is more than computer as it provides access to the on-chip hardware i.e. GPIOs
for developing an application. By accessing GPIO, we can connect devices like LED, motors,
sensors, etc and can control them too.
It has ARM based Broadcom Processor SoC along with on-chip GPU (Graphics Processing
Unit).
The CPU speed of Raspberry Pi varies from 700 MHz to 1.2 GHz. Also, it has on-board
SDRAM that ranges from 256 MB to 1 GB.
Raspberry Pi also provides on-chip SPI, I2C, I2S and UART modules. There are different
versions of raspberry pi available as listed below:
1. Raspberry Pi 1 Model A
2. Raspberry Pi 1 Model A+
3. Raspberry Pi 1 Model B
4. Raspberry Pi 1 Model B+
5. Raspberry Pi 2 Model B
6. Raspberry Pi 3 Model B
7. Raspberry Pi Zero
Page no.: 20
Shree Swaminarayan Institute of Technology CE/IT DEPT. (VI Semester)
PRACTICAL: 11
Aim: Write a program for blinking led using Raspberry PI.
Source Code:
Output:
Page no.: 21
Shree Swaminarayan Institute of Technology CE/IT DEPT. (VI Semester)
PRACTICAL: 12
Aim: Write a program for Fade in led (increasing and decreasing
brightness) using Raspberry PI .
Source Code:
Output:
Page no.: 22
Shree Swaminarayan Institute of Technology CE/IT DEPT. (VI Semester)
PRACTICAL: 13
Aim: Write a program for demonstrating IR sensor using Raspberry PI.
Source Code:
Output:
Page no.: 23