Professional Documents
Culture Documents
IOT Practical File
IOT Practical File
IOT Practical
PRACTICAL FILE
INTERNET OF THINGS
(UGCA 1933)
Submitted To :
Submitted By :
Kiran Jyoti Mehra
Sanjeev Kumar Panda
Roll No : 1926933
BSC IT 6th
INDEX
Experiment No 1
How it works?
First we read the push-button state using digitalRead() function. In this
experiment we use if else statement to control the servo motor according to the
condition. Arduino Uno continuously monitor state of the push-button. When
the push-button sate become high, Arduino write the servo to 180 degree.
Otherwise it keeps at 0 degree.
First we need to know what is push-button. It will help to use the push-button in
all aspects and anywhere
Push-button
In simple words, It is a simple switch which only on/conduct when the button is
pressed. Most of the push-buttons are designed to operate with human hand. So,
the top of the push-button always a flat structure. Here we using a PCB mount
type push-button.
Next we need to know what is pull-up resistor.
Pull-up Resistor
In the circuit diagram, You can find a 10 Kilo Ohm resistor connected to the
push-button. Here it is used as pull-up resistor. It is used to ensure a known state
(here it is HIGH) for a signal. When switch/push-button is closed it create a
direct path to Ground. But when switch/push-button is opened, there will be a
well defined logic HIGH at signal.
First add the header file for servo motor and declare a variable to call the Servo
motor. Here I am using the variable name as "Myservo"
#include<Servo.h>
Servo Mysevo;
Step - 2
In void setup() function, declare the Servo pin by the "attach()" function. in this
project we use the Arduino digital pin 3 to this purpose. Then we need to set the
pin to read the pushbutton, as "INPUT"
Myservo.attach(3)'
pinMode(2,INPUT);
Setup part is completed.
Step - 3
In the void loop() function we need to use if and else to make a diction. When
the push-button is pressed the output of the push-button be logic LOW. This
push-button output is read by digitalRead() function. Here we use the Arduino
Uno Digital pin 2 is used to this purpose. Then write the servo to 180 degree.
if(digitalRead(2)==LOW){
Myservo.write(180);
}
Otherwise Servo position keep as 0 degree.
else{
Myservo.write(0);
}
The coding part is completed. Double check for errors and upload the code to
Arduino Uno.
Now we need to make the circuit. Here we are using PCB mound type push-
button. So solder the push-button and resistor on the Dot PCB.
Circuit diagram:
CODE
Control Servo Motor with Arduino and push-buttonArduino
//sketch created by Akshay Joseph follow me on Instagra: five_volt_player
include<Servo.h>
Servo Myservo;
int pos=0;
void setup()
{
pinMode(2,INPUT);
Myservo.attach(3);
}
void loop()
{
if(digitalRead(2)==LOW){
Myservo.write(180);
}
else
Myservo.write(0);
Outcomes:
Student will be able to understand how to Control Servo Motor with push-
button using Arduino uno.
Applications:
Servomotor used in camera zooms, lift doors, or tools we may have at home.
Servo motors are also used in industrial applications, robotics, in-line
manufacturing, pharmaceutics, and food services.
Experiment No. 2
• Description
You can retrieve data from the Internet of Things website by using ThingSpeak
to download the data to your target hardware.
ThingSpeak is an application platform that you can use for the Internet of
Things. You can build an application around data that is collected by sensors.
ThingSpeak includes real-time data collection, data processing, visualizations,
apps, and plugins.
You can see the ThingSpeak server response to a data download request by
selecting the Print diagnostic messages option. This option has no effect when
you use External mode, Serial Transmit, or Serial Receive blocks that use port
0.
• Parameters
Channel ID
1. Get the Channel ID parameter from your channel on ThingSpeak.com.
Channel Access
By default, the ThingSpeak channel access is private. To access the channel,
you must have a read API key.
You can make the channel public to allow other users to use your feed without a
Read API key.
Field Number
Specify a field that you want to read from the ThingSpeak channel.
Sample time
Specify in seconds how often this block reads the ThingSpeak channel..
Outcomes:
Student will be able to understand how can retrieve data from the Internet of
Things website by using ThingSpeak to download the data to your target
hardware.
Applications:
Machine learning uses data and produces a program to perform a task.
Application is Cloud-based people counter by detecting faces with the
Computer Vision System. The raw people count is then sent to the ThingSpeak
IoT platform for data collection in the cloud and further data analysis.
Experiment no 3
In case you use Arduino Nano, you will need an A to Mini-B cable instead as
shown in the following image.
with your operating system (Windows, IOS, or Linux). After your file
download is complete, unzip the file.
11
12
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.
13
Here, we have selected Arduino Uno board according to our tutorial, but you
must select the name matching the board that you are using.
14
15
Outcomes:
Applications:
16
Experiment No 4
Explanation: LEDs are small, powerful lights that are used in many different
applications. To start, we will work on blinking an LED, the Hello World of
microcontrollers. It is as simple as turning a light on and off. Establishing this
important baseline will give you a solid foundation as we work towards
experiments that are more complex.
Components Required:
You will need the following components −
• 1 × Breadboard
• 1 × Arduino Uno R3
• 1 × LED
• 1 × 330Ω Resistor
• 2 × Jumper
Procedure
Follow the circuit diagram and hook up the components on the breadboard as
shown in the image given below.
17
Note − To find out the polarity of an LED, look at it closely. The shorter of the
two legs, towards the flat edge of the bulb indicates the negative terminal.
Components like resistors need to have their terminals bent into 90° angles in
order to fit the breadboard sockets properly. You can also cut the terminals
shorter.
18
Sketch
Open the Arduino IDE software on your computer. Coding in the Arduino
language will control your circuit. Open the new sketch File by clicking New.
Arduino Code
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
*/
// the setup function runs once when you press reset or power the board
void loop() {
digitalWrite(2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
19
digitalWrite(2, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Code to Note
pinMode(2, OUTPUT) − Before you can use one of Arduino’s pins, you need
to tell Arduino Uno R3 whether it is an INPUT or OUTPUT. We use a built-in
“function” called pinMode() to do this.
digitalWrite(2, HIGH) − When you are using a pin as an OUTPUT, you can
command it to be HIGH (output 5 volts), or LOW (output 0 volts).
Result
You should see your LED turn on and off. If the required output is not seen,
make sure you have assembled the circuit correctly, and verified and uploaded
the code to your board.
Outcomes:
Applications:
Uses Arduino UNO: LED emergency lights for use on model / toy vehicles and
other projects.
20
Experiment No. 5
We connect three wires to the Arduino board. The first goes from one leg of the
pushbutton through a pull-up resistor (here 2.2 KOhms) to the 5 volt supply.
The second goes from the corresponding leg of the pushbutton to ground. The
third connects to a digital i/o pin (here pin 7) which reads the button's state.
Schematic:
21
* http://arduino.berlios.de
*/
22
void setup() {
void loop(){
} else {
23
Outcomes:
Student will be able to understand how to interface with digital sensor and push
buttons and its installation on Ardunio Uno.
Applications:
Experiment No 6
Explanation:
Control Servo motor with Arduino Uno and Push-button
How it works?
First we read the push-button state using digitalRead() function. In this
experiment we use if else statement to control the servo motor according to the
condition. Arduino Uno continuously monitor state of the push-button. When
the push-button sate become high, Arduino write the servo to 180 degree.
Otherwise it keeps at 0 degree.
First we need to know what is push-button. It will help to use the push-button in
all aspects and anywhere
24
Push-button
In simple words, It is a simple switch which only on/conduct when the button is
pressed. Most of the push-buttons are designed to operate with human hand. So,
the top of the push-button always a flat structure. Here we using a PCB mount
type push-button.
Next we need to know what is pull-up resistor.
Pull-up Resistor
In the circuit diagram, You can find a 10 Kilo Ohm resistor connected to the
push-button. Here it is used as pull-up resistor. It is used to ensure a known state
(here it is HIGH) for a signal. When switch/push-button is closed it create a
direct path to Ground. But when switch/push-button is opened, there will be a
well defined logic HIGH at signal.
Step - 2
In void setup() function, declare the Servo pin by the "attach()" function. in this
project we use the Arduino digital pin 3 to this purpose. Then we need to set the
pin to read the pushbutton, as "INPUT"
Myservo.attach(3)'
pinMode(2,INPUT);
25
if(digitalRead(2)==LOW){
Myservo.write(180);
}
Otherwise Servo position keep as 0 degree.
else{
Myservo.write(0);
}
The coding part is completed. Double check for errors and upload the code to
Arduino Uno.
Now we need to make the circuit. Here we are using PCB mound type push-
button. So solder the push-button and resistor on the Dot PCB.
Circuit diagram:
CODE
Control Servo Motor with Arduino and push-buttonArduino
//sketch created by Akshay Joseph follow me on Instagra: five_volt_player
include<Servo.h>
Servo Myservo;
int pos=0;
void setup()
{
26
pinMode(2,INPUT);
Myservo.attach(3);
}
void loop()
{
if(digitalRead(2)==LOW){
Myservo.write(180);
}
else
Myservo.write(0);
Outcomes:
Student will be able to understand how to Control Servo Motor with push-
button using Arduino uno.
Applications:
Servomotor used in camera zooms, lift doors, or tools we may have at home.
Servo motors are also used in industrial applications, robotics, in-line
manufacturing, pharmaceutics, and food services.
27
Experiment No. 7
There are three main parts to this project. An Android smartphone, a Bluetooth
transceiver, and an Arduino.
28
This circuit is simple and small. There are only four connections to be made
between the Arduino and Bluetooth module!
29
You can connect the Bluetooth module to the Arduino using a set of jumper
wires and a connector.
30
data = Serial.read(); //Read the incoming data and store it into variable data
Serial.print(data); //Print Value inside data in Serial monitor
Serial.print("\n"); //New line
if(data == '1') //Checks whether value of data is equal to 1
digitalWrite(13, HIGH); //If value is 1 then LED turns ON
else if(data == '0') //Checks whether value of data is equal to 0
digitalWrite(13, LOW); //If value is 0 then LED turns OFF
}
You can download the Android application from here and the source code of the
entire project.
31
32
Outcomes:
Applications:
This work can be taken to a higher level, like home automation using a
smartphone, smartphone-controlled robots.
33