CERTIFICATE
This is to certify that the practical/term work carried in subject
of Internet of Things (IT802-N) and recorded in this journal
is the bonafide work of Student Name:
Khanpara Parthiv Laxmanbhai & Enrollment No:
21BEIT54020 of B.E. Year 4th Semester 8th in the branch of
IT during the academic year 2024-2025 within the four walls
of this institute.
Date:
Faculty in charge Head of the Department
ENROLLMENT NO.: 21BEIT54020 VSITR (IT)
PRACTICAL: 1
Aim: Introduction to Arduino Board, Arduino IDE and Cables.
Arduino is an open-source platform used for building electronics projects.
Arduino consists of both a physical programmable circuit board (often referred
to as a microcontroller) and a piece of software, or IDE (Integrated Development
Environment) that runs on your computer, used to write and upload computer
code to the physical board.
The Arduino platform has become quite popular with people just starting out with
electronics, and for good reason. Unlike most previous programmable circuit
boards, the Arduino does not need a separate piece of hardware (called a
programmer) in order to load new code onto the board -- you can simply use a
USB cable. Additionally, the Arduino IDE uses a simplified version of C++,
making it easier to learn to program. Finally, Arduino provides a standard form
factor that breaks out the functions of the micro-controller into a more accessible
package.
1
ENROLLMENT NO.: 21BEIT54020 VSITR (IT)
The key features are −
Arduino boards are able to read analog or digital input signals from
different sensors and turn it into an output such as activating a motor,
turning LED on/off, connect to the cloud and many other actions.
You can control your board functions by sending a set of instructions
to the microcontroller on the board via Arduino IDE (referred to as
uploading software).
Unlike most previous programmable circuit boards, Arduino does not
need an extra piece of hardware (called a programmer) in order to load
a new code onto the board. You can simply use a USB cable.
Additionally, the Arduino IDE uses a simplified version of C++,
making it easier to learn to program.
Finally, Arduino provides a standard form factor that breaks the
functions of the micro-controller into a more accessible package.
2
ENROLLMENT NO.: 21BEIT54020 VSITR (IT)
What's on the board?
There are many varieties of Arduino boards (explained on the next
page) that can be used for different purposes. Some boards look a bit
different from the one below, but most Arduinos have the majority of
these components in common:
3
ENROLLMENT NO.: 21BEIT54020 VSITR (IT)
Power (USB / Barrel Jack)
Every Arduino board needs a way to be connected to a power source.
The Arduino UNO can be powered from a USB cable coming from
your computer or a wall power supply (like this) that is terminated in a
barrel jack. In the picture above the USB connection is labeled (1) and
the barrel jack is labeled (2).
The USB connection is also how you will load code onto your Arduino
board. More on how to program with Arduino can be found in our
Installing and Programming Arduino tutorial.
4
ENROLLMENT NO.: 21BEIT54020 VSITR (IT)
NOTE: Do NOT use a power supply greater than 20 Volts as you will
overpower (and thereby destroy) your Arduino. The recommended
voltage for most Arduino models is between 6 and 12 Volts.
Pins (5V, 3.3V, GND, Analog, Digital, PWM, AREF)
The pins on your Arduino are the places where you connect wires to
construct a circuit (probably in conjuction with a breadboard and some
wire. They usually have black plastic ‘headers’ that allow you to just
plug a wire right into the board. The Arduino has several different kinds
of pins, each of which is labeled on the board and used for different
functions.
GND (3): Short for ‘Ground’. There are several GND pins on the
Arduino, any of which can be used to ground your circuit.
5V (4) & 3.3V (5): As you might guess, the 5V pin supplies 5 volts of
power, and the 3.3V pin supplies 3.3 volts of power. Most of the simple
components used with the Arduino run happily off of 5 or 3.3 volts.
Analog (6): The area of pins under the ‘Analog In’ label (A0 through
A5 on the UNO) are Analog In pins. These pins can read the signal
from an analog sensor (like a temperature sensor) and convert it into a
digital value that we can read.
Digital (7): Across from the analog pins are the digital pins (0 through
13 on the UNO). These pins can be used for both digital input (like
telling if a button is pushed) and digital output (like powering an LED).
PWM (8): You may have noticed the tilde (~) next to some of the
digital pins (3, 5, 6, 9, 10, and 11 on the UNO). These pins act as normal
digital pins, but can also be used for something called Pulse-Width
Modulation (PWM). We have a tutorial on PWM, but for now, think of
these pins as being able to simulate analog output (like fading an LED
in and out).
5
ENROLLMENT NO.: 21BEIT54020 VSITR (IT)
AREF (9): Stands for Analog Reference. Most of the time you can
leave this pin alone. It is sometimes used to set an external reference
voltage (between 0 and 5 Volts) as the upper limit for the analog input
pins.
Reset Button
Just like the original Nintendo, the Arduino has a reset button (10).
Pushing it will temporarily connect the reset pin to ground and restart
any code that is loaded on the Arduino. This can be very useful if your
code doesn’t repeat, but you want to test it multiple times. Unlike the
original Nintendo however, blowing on the Arduino doesn't usually fix
any problems.
Power LED Indicator
Just beneath and to the right of the word “UNO” on your circuit board,
there’s a tiny LED next to the word ‘ON’ (11). This LED should light
up whenever you plug your Arduino into a power source. If this light
doesn’t turn on, there’s a good chance something is wrong. Time to re-
check your circuit!
TX RX LEDs
TX is short for transmit, RX is short for receive. These markings appear
quite a bit in electronics to indicate the pins responsible for serial
communication. In our case, there are two places on the Arduino UNO
where TX and RX appear -- once by digital pins 0 and 1, and a second
time next to the TX and RX indicator LEDs (12). These LEDs will give
us some nice visual indications whenever our Arduino is receiving or
transmitting data (like when we’re loading a new program onto the
board).
Main IC
The black thing with all the metal legs is an IC, or Integrated Circuit
(13). Think of it as the brains of our Arduino. The main IC on the
Arduino is slightly different from board type to board type, but is
usually from the ATmega line of IC’s from the ATMEL company. This
6
ENROLLMENT NO.: 21BEIT54020 VSITR (IT)
can be important, as you may need to know the IC type (along with
your board type) before loading up a new program from the Arduino
software. This information can usually be found in writing on the top
side of the IC. If you want to know more about the difference between
various IC's, reading the datasheets is often a good idea.
Voltage Regulator
The voltage regulator (14) is not actually something you can (or should)
interact with on the Arduino. But it is potentially useful to know that it
is there and what it’s for. The voltage regulator does exactly what it
says -- it controls the amount of voltage that is let into the Arduino
board. Think of it as a kind of gatekeeper; it will turn away an extra
voltage that might harm the circuit. Of course, it has its limits, so don’t
hook up your Arduino to anything greater than 20 volts.
The Arduino Family
Arduino makes several different boards, each with different
capabilities. In addition, part of being open source hardware means that
others can modify and produce derivatives of Arduino boards that
provide even more form factors and functionality.
7
ENROLLMENT NO.: 21BEIT54020 VSITR (IT)
PRACTICAL: 2
Aim: Perform Practical to blink LED on Arduino Board and
external LED as well.
It is the simple basic project created using Arduino. LED (Light
Emitting Diode) is an electronic device, which emits light when the
current passes through its terminals. LED's are used in various
applications. It is also used as an ON/OFF indicator in different
electronic devices.
In this project, we will connect the LED to the digital pin on the
Arduino board. The LED will work as a simple light that can be turned
ON and OFF for a specified duration.
Structure of LED
An LED is a two-terminal device. The two terminals are called as
Cathode and Anode.
It is shown below:
The long terminal is called Anode, and the shorter terminal is called
Cathode. Here, cathode is the negative terminal and anode is the
positive terminal.
Components of the project
8
ENROLLMENT NO.: 21BEIT54020 VSITR (IT)
The components used in the blinking of an LED are listed below:
1. 1 x Arduino UNO board.
2. We can use any version of the UNO board, such as UNO R3, etc.
We can also use other types of Arduino boards, such as Arduino
Zero, Arduino Micro, etc.
3. 1 x Breadboard
4. 2 x Jump wires
5. 1 x LED
6. 1 x Resistor of 220 Ohm.
We can use a resistor of any value upto 470 Ohms. We can use other
value of resistors as well, depending on our circuit requirements.
Usually, the value should not exceed the allowable forward current.
Structure of the project
The structure clearly shows the pinout of the UNO board. It also
displays the LED and resistance connected to the board.
It is shown below:
9
ENROLLMENT NO.: 21BEIT54020 VSITR (IT)
Sketch
We need to install the Arduino IDE, to begin with the coding, which is
already discussed.
Open the IDE and start with the coding, which is given below:
void setup ()
pinMode ( 8, OUTPUT); // to set the OUTPUT mode of pin number 8.
void loop ()
digitalWrite (8, HIGH);
10
ENROLLMENT NO.: 21BEIT54020 VSITR (IT)
delay(1000); // 1 second = 1 x 1000 milliseconds
digitalWrite (8, LOW);
delay(500); // 0.5 second = 0.5 x 1000 milliseconds
We can modify the delay duration according to our choice or as per the
requirements.
Every statement of coding is explained in Arduino coding basics. You
can open the URL for clear understanding.
The sketch will be uploaded to the board after the correct compiling, as
shown below:
We are required to click on the Verify button to compile the code.
11
ENROLLMENT NO.: 21BEIT54020 VSITR (IT)
The RX and TX LED on the board will light up after the successful
uploading of the code.
Procedure
The procedure to join the components of the project is shown below:
Attach an LED on the breadboard. We need to plug-in the two terminals
of an LED into the holes of the breadboard.
We can plug-in the LED anywhere on the breadboard.
Connect the resistor in series with the LED, as shown below:
Connect the left leg of the resistor (connected in series with red LED)
to the digital output pin of the UNO board, i.e., PIN 8.
Connect the negative/shorter terminal (Cathode) of the LED to the
GND pin of the UNO board using the wire, as shown below:
12
ENROLLMENT NO.: 21BEIT54020 VSITR (IT)
Here, the orange wire is connected to the PIN 8, and the blue wire is
connected to the GND.
The shorter terminal indicates the negative. So, we will connect the
shorter terminal to the Ground (GND).
Connect the USB cable.
Select the board and serial port in the Arduino IDE.
Upload the sketch or code on the board.
The LED will dim and light for the specified duration.
13
ENROLLMENT NO.: 21BEIT54020 VSITR (IT)
PRACTICAL: 3
Aim: Design an IOT application to use the concept of RFID Sensor.
Code: -
void setup ()
pinMode(LED_BUILTIN, OUTPUT);
void loop ()
digitalWrite(LED_BUILTIN, HIGH);
delay(1000); // Wait for 1000 millisecond(s)
digitalWrite(LED_BUILTIN, LOW);
delay(1000); // Wait for 1000 millisecond(s)}
14
ENROLLMENT NO.: 21BEIT54020 VSITR (IT)
15
ENROLLMENT NO.: 21BEIT54020 VSITR (IT)
PRACTICAL: 4
Aim: Design and implement the concept of Flex Sensor.
Code:
#include <Servo.h>
Servo myServo;
# define flexPin A0
void setup() {
myServo.attach(3);
Serial.begin(9600);}
void loop() {
int flexValue;
int servoPosition;
16
ENROLLMENT NO.: 21BEIT54020 VSITR (IT)
flexValue = analogRead(flexPin);
servoPosition = map(flexValue, 770, 950, 0, 180);
servoPosition = constrain(servoPosition, 0, 180);
myServo.write(servoPosition);
Serial.print("sensor =");
Serial.println(flexValue);
Serial.print("servo =");
Serial.println(servoPosition);
delay(20);}
Output:
17
ENROLLMENT NO.: 21BEIT54020 VSITR (IT)
PRACTICAL: 5
Aim: Implement the concept of IR Sensor.
Code:
#include <IRremote.h>
int RECV_PIN = 2;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
Serial.begin(9600);
irrecv.enableIRIn();}
void loop(){
18
ENROLLMENT NO.: 21BEIT54020 VSITR (IT)
if(irrecv.decode(&results)){ //1 is turn led on
Serial.println(results.value, HEX);
switch(results.value){
case 0xFD08F7:
digitalWrite(13, HIGH);
break;
case 0xFD8877:
digitalWrite(13, LOW); // Red Dot is Off
irrecv.resume(); }
delay(100);
Output:
19
ENROLLMENT NO.: 21BEIT54020 VSITR (IT)
PRACTICAL: 6
Aim: Implement the concept of Piezo Vibration Sensor.
Code:
const int UltrasonikTrig1 = 11;
const int UltrasonikEcho1 = 12;
const int Indikator = 10;
void setup() {
Serial.begin(9600);
pinMode(UltrasonikTrig1, OUTPUT);
pinMode(UltrasonikEcho1, INPUT);
pinMode(Indikator, OUTPUT);
20
ENROLLMENT NO.: 21BEIT54020 VSITR (IT)
long duration1;
long cm1;
void loop()
digitalWrite(UltrasonikTrig1, LOW);
digitalWrite(UltrasonikTrig1, HIGH);
delayMicroseconds(10);
digitalWrite(UltrasonikTrig1, LOW);
duration1 = pulseIn(UltrasonikEcho1, HIGH);
cm1 = microsecondsKeCenti(duration1);
Serial.print("Sensor 1 : ");
Serial.print(cm1);
Serial.print(" cm");
Serial.print(" || ");
// if the distance less than 100 cm / 1 meter
if (cm1 <= 100)
digitalWrite(Indikator, HIGH);
else
21
ENROLLMENT NO.: 21BEIT54020 VSITR (IT)
digitalWrite(Indikator, LOW);
Serial.print(" Save");
Serial.println(" || ");
delay(100);
long microsecondsKeCenti(long microseconds)
return microseconds / 29 / 2;
Output:
22
ENROLLMENT NO.: 21BEIT54020 VSITR (IT)
PRACTICAL: 7
Aim: Implement the concept of Accelerometer.
Code:
const int x_pin = A0;
const int y_pin = A1;
const int z_pin = A2;
// Volts per G-Force
const float sensitivity = 0.206;
void setup() {
analogReference(EXTERNAL);
Serial.begin(9600);
23
ENROLLMENT NO.: 21BEIT54020 VSITR (IT)
void loop() {
float x;
float y;
float z;
// Read pins and convert to G
x = (analogRead(x_pin) - 512) * 3.3 / (sensitivity * 1023);
y = (analogRead(y_pin) - 512) * 3.3 / (sensitivity * 1023);
z = (analogRead(z_pin) - 512) * 3.3 / (sensitivity * 1023);
// Display acceleration
Serial.print("x: ");
Serial.print(x);
Serial.print(" y: ");
Serial.print(y);
Serial.print(" z: ");
Serial.println(z);
delay(100);
#include<Wire.h>
const int MPU=0x68;
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;
24
ENROLLMENT NO.: 21BEIT54020 VSITR (IT)
void setup(){
Wire.begin();
Wire.beginTransmission(MPU);
Wire.write(0x6B);
Wire.write(0);
Wire.endTransmission(true);
Serial.begin(9600);
void loop(){
Wire.beginTransmission(MPU);
Wire.write(0x3B);
Wire.endTransmission(false);
Wire.requestFrom(MPU,12,true);
AcX=Wire.read()<<8|Wire.read();
AcY=Wire.read()<<8|Wire.read();
AcZ=Wire.read()<<8|Wire.read();
GyX=Wire.read()<<8|Wire.read();
GyY=Wire.read()<<8|Wire.read();
GyZ=Wire.read()<<8|Wire.read();
Serial.print("Accelerometer: ");
Serial.print("X = "); Serial.print(AcX);
25
ENROLLMENT NO.: 21BEIT54020 VSITR (IT)
Serial.print(" | Y = "); Serial.print(AcY);
Serial.print(" | Z = "); Serial.println(AcZ);
Serial.print("Gyroscope: ");
Serial.print("X = "); Serial.print(GyX);
Serial.print(" | Y = "); Serial.print(GyY);
Serial.print(" | Z = "); Serial.println(GyZ);
Serial.println(" ");
delay(333);
Output:
26
ENROLLMENT NO.: 21BEIT54020 VSITR (IT)
PRACTICAL: 8
Aim: Implement the concept of Temperature and Humidity
Sensor.
Code:
int potReading;
int motorPower;
void setup()
pinMode(A0,INPUT); //potentiometer
Serial.begin(9600);
27
ENROLLMENT NO.: 21BEIT54020 VSITR (IT)
void loop()
potReading = analogRead(A0);//read value from potentiometer - 0-
1023
Serial.println(potReading); //print value
//lets say normal mositure levels are 500-900
if (potReading>900)//if moisture content is high
motorPower = map(analogRead(A0), 900, 1023, 0, 255);//set motor
power proportional to moisture content
analogWrite(5,motorPower);//send power to fan motor
analogWrite(6,0);
else if (potReading <500)//if moisture content is low
motorPower = map(analogRead(A0), 500, 0, 0, 255);//set motor
power inversely proportional to moisture content
analogWrite(6,motorPower);//send power to humidifier motor
analogWrite(5,0);
else //if moisture content is within optimal levels, do nothing
28
ENROLLMENT NO.: 21BEIT54020 VSITR (IT)
analogWrite(5,0);
analogWrite(6,0);
delay(1000); // Wait for 1000 millisecond(s)
Output:
29
ENROLLMENT NO.: 21BEIT54020 VSITR (IT)
PRACTICAL: 9
Aim: Implement the concept of flame Sensor.
Code:
int fl=5;
int buz=6;
int led=8;
int flag;// status
void setup() {
// put your setup code here, to run once:
pinMode(fl,INPUT);
pinMode(buz,OUTPUT);
pinMode(led,OUTPUT);
Serial.begin(9600);}
void loop() {
30
ENROLLMENT NO.: 21BEIT54020 VSITR (IT)
// put your main code here, to run repeatedly:
flag= digitalRead(fl);
if( flag==1){
digitalWrite(buz,HIGH);
digitalWrite(led,HIGH);
Serial.println("Flame detected");
delay(2000);}
else{
digitalWrite(buz,LOW);
digitalWrite(led,LOW);
Serial.println("Flame detected");
delay(2000);}
Output:
31
ENROLLMENT NO.: 21BEIT54020 VSITR (IT)
PRACTICAL: 10
Aim: Implement the concept of buzzer Sensor.
Code:
int val = A0;
void setup()
pinMode (9,OUTPUT);
pinMode (A0,INPUT);
Serial.begin(9600);
void loop()
val = analogRead (A0);
32
ENROLLMENT NO.: 21BEIT54020 VSITR (IT)
if (val <500 )
{digitalWrite (9, LOW);}
else
{digitalWrite(9, HIGH);}
Output:
33