Report Demo

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 36

Seminar Report

“ Internet of Things And Programming”

SUBMITTED BY :
MR. SHAHEBAZ AJMER PATHAN
(BCA TY STUDENT)
Roll no 218
Seat no
REW2453029

UNDER GUIDANCE OF :
PROF. DR . S. V. PATIL

Internet of Things And 1


Programming
ACKNOWLEGEMENT
I would like to express my sincere gratitude to all those who have
contributed to the successful completion of this seminar report on "Internet
of Things and Programming."

Firstly, I would like to thank Dr. S.V. Patil ,My seminar guide, for their
invaluable guidance, constant support, and encouragement throughout this
project. Their deep knowledge and insightful suggestions have been
instrumental in shaping the direction and depth of this report.

I also wish to thank Department of Information Technology for providing the


necessary resources and a conducive environment to conduct research and
compile this report.

Special thanks to my Parents, classmates and friends who have provided


me with their support and shared their knowledge and expertise. The
discussions and feedback from them have greatly enhanced the quality of
this report.

Finally, I would like to extend my gratitude to my family for their unwavering


support and encouragement during the preparation of this seminar. Their
patience and understanding have been a great source of strength.

Thank you all for your contributions and assistance in making this seminar
report a success.

---

Internet of Things And 2


Programming
TABLE OF CONTENT

Sr. No. Content Page No.

1. Aims and Objectives 5

2. Introduction 6

3. Hardware 9

4. Sensors 10

5. Software 15

6. Ardiuno 18

7. Programming 22

8. Example Project 30

9. Conclusion 34

10. References 36

Internet of Things And 3


Programming
ABSTRACT

Internet of Things And 4


Programming
AIMS AND OBJECTIVES

Aims:

To Explore the Concept of the Internet of Things (IoT): This


seminar report aims to provide a thorough understanding of the
Internet of Things, including its definition, evolution, and the
underlying technologies that enable its operation.

To Examine the Role of Programming in IoT Development: The


report seeks to delve into how programming facilitates the
functionality of IoT systems, focusing on the various programming
languages, frameworks, and tools used in the development of IoT
applications.

To Analyze the Challenges and Solutions in IoT Programming:


Another key aim is to identify and analyze the major challenges
associated with IoT programming, such as security, scalability, and
interoperability, and to explore current and emerging solutions to
address these challenges.

Objectives:

To Provide a Comprehensive Overview of IoT Technologies:

Describe the fundamental components of IoT systems, including


sensors, actuators, and communication protocols.

To Investigate Programming Languages and Tools Used in IoT:

Discuss the programming languages commonly used in IoT


development, such as C, C++, Python, and JavaScript.

Internet of Things And 5


Programming
INTRODUCTION
The Internet of Things (IoT) represents one of the most significant
technological advancements in recent history, heralding a new era in which
the physical and digital worlds converge seamlessly. As a concept, IoT refers
to the network of physical objects—devices, vehicles, appliances, and more
—embedded with sensors, software, and other technologies that enable
them to connect and exchange data with other devices and systems over
the internet. The IoT ecosystem is characterized by its vast diversity,
encompassing everything from wearable fitness trackers and smart home
devices to industrial sensors and connected vehicles. By integrating these
disparate elements into a cohesive network, IoT facilitates unprecedented
levels of automation, efficiency, and convenience, fundamentally
transforming how we live, work, and interact with our environment.

The concept of IoT is not entirely new; the idea of connecting objects and
devices has been around for several decades. However, it is only in the last
decade that IoT has gained significant traction, largely due to the
convergence of multiple technological advancements. These include the
proliferation of low-cost sensors and actuators, the widespread availability
of high-speed internet, advancements in cloud computing, and the
development of robust data analytics and machine learning algorithms.
Together, these technologies have created a fertile ground for the growth of
IoT, enabling the development of smart, interconnected systems that can
monitor, analyze, and respond to their surroundings in real time.

Programming plays a crucial role in the functioning of IoT systems. At its


core, IoT is about communication—devices must be able to send and
receive data, interpret that data, and then take appropriate action. This
requires a complex interplay of software and hardware, where programming
becomes the key enabler of functionality and interoperability. The
programming of IoT devices involves writing code that governs the behavior
of individual devices, as well as developing the software that manages and
coordinates entire networks of devices. This includes everything from low-
level firmware programming that allows a device to communicate with its
sensors and actuators to high-level application programming that provides
users with control and analytics capabilities.

One of the key characteristics of IoT programming is the need for efficiency
and optimization. IoT devices often operate in resource-constrained
environments, with

Internet of Things And 6


Programming
limited processing power, memory, and energy availability. This
necessitates the use of lightweight programming languages and
frameworks, such as C, C++, and Python, as well as specialized IoT
operating systems like FreeRTOS and Contiki. Moreover, IoT programming
often involves the development of real-time systems, where the timely
processing and transmission of data are critical. This requires programmers
to have a deep understanding of both hardware and software, as well as a
strong grasp of embedded systems design principles.

Security is another critical aspect of IoT programming. Given the sheer


number of devices involved in IoT networks and the sensitive nature of the
data they often handle, ensuring the security and privacy of IoT systems is
of paramount importance. This involves implementing robust encryption
and authentication mechanisms, as well as developing secure
communication protocols and network architectures. IoT programming must
also account for potential vulnerabilities that could be exploited by
malicious actors, requiring a proactive approach to security that includes
regular updates and patches.

In addition to security, IoT programming must also consider scalability and


interoperability. As the number of IoT devices continues to grow
exponentially, the ability to scale IoT systems efficiently becomes
increasingly important. This requires the development of scalable
architectures and communication protocols that can support large numbers
of devices and handle the associated data traffic. Interoperability is equally
important, as IoT systems often involve devices from multiple
manufacturers, each with its own proprietary protocols and standards. To
ensure seamless communication and integration, IoT programming must
adhere to open standards and protocols, such as MQTT, CoAP, and HTTP, as
well as develop middleware solutions that can bridge the gap between
different systems.

The impact of IoT on various industries and sectors cannot be overstated. In


the industrial sector, IoT has given rise to the concept of the Industrial
Internet of Things (IIoT), where connected sensors and devices are used to
monitor and optimize manufacturing processes, improve supply chain
management, and enhance equipment maintenance. In the healthcare
sector, IoT enables remote patient monitoring, telemedicine, and smart
medical devices, improving patient outcomes and reducing healthcare
costs. In the smart home and consumer electronics markets, IoT devices
provide convenience and automation, allowing users to control everything
from lighting and heating to security systems and home appliances through
their smartphones or voice assistants.
Internet of Things And 7
Programming
However, the rapid proliferation of IoT devices also presents several
challenges. The sheer volume of data generated by IoT devices poses
significant storage and processing challenges, necessitating the use of
advanced data analytics and cloud computing solutions. The heterogeneity
of IoT devices and the lack of standardization across the industry also pose
interoperability challenges, making it difficult for different systems to
communicate and work together effectively. Moreover, the security and
privacy concerns associated with IoT cannot be ignored, as the increasing
number of connected devices provides more entry points for potential
cyberattacks.

To address these challenges, ongoing research and development are


focused on advancing IoT technologies and improving their security,
scalability, and interoperability. This includes the development of new
communication protocols and standards, the use of artificial intelligence and
machine learning to enhance data processing and decision-making, and the
exploration of edge computing as a way to reduce latency and improve data
security. By bringing computing power closer to the source of data, edge
computing can help mitigate some of the limitations of cloud- based IoT
systems, enabling faster and more secure processing of data.

In conclusion, the Internet of Things represents a transformative force that


is reshaping our world in profound ways. By connecting devices and
enabling them to communicate and collaborate, IoT is driving innovation
across a wide range of industries and applications, from smart cities and
autonomous vehicles to precision agriculture and environmental monitoring.
At the heart of this revolution is programming, which serves as the engine
that powers IoT systems and enables them to function effectively. As the IoT
ecosystem continues to evolve and expand, the role of programming will
only become more critical, requiring a new generation of developers who
are equipped with the skills and knowledge needed to navigate this complex
and dynamic field. Through continued innovation and collaboration, the
potential of IoT to improve our lives and solve some of the world's most
pressing challenges is limitless.

Internet of Things And 8


Programming
HARDWARE

The hardware utilized in IoT systems includes devices for a remote


dashboard, devices for control, servers, a routing or bridge device, and
sensors. These devices manage key tasks and functions such as system
activation, action specifications, security, communication, and detection to
support-specific goals and actions.

IoT − Sensors

The most important hardware in IoT might be its sensors. These devices
consist of energy modules, power management modules, RF modules, and
sensing modules. RF modules manage communications through their signal
processing, WiFi, ZigBee, Bluetooth, radio transceiver, duplexer, and BAW.

The sensor attains a physical parameter and converts it into a signal


suitable for processing (e.g. electrical, mechanical, optical) the
characteristics of any device or material to detect the presence of a
particular physical quantity.

The output of the sensor is a signal which is converted to a human-readable


form like changes in characteristics, changes in resistance, capacitance,
impedance, etc.

Internet of Things And 9


Programming
1. Transducer :

A transducer converts a signal from one physical structure to


another. It converts one type of energy into another type.

It might be used as actuator in various systems.

1. Static characteristics :

It is about how the output of a sensor changes in response to an input


change after steady state condition.

Accuracy: Accuracy is the capability of measuring instruments to give a


result close to the true value of the measured quantity. It measures errors.
It is measured by absolute and relative errors. Express the correctness of
the output compared to a higher prior system. Absolute error = Measured
value – True value

Relative error = Measured value/True value

Range: Gives the highest and the lowest value of the physical quantity
within which the sensor can actually sense. Beyond these values, there is no
sense or no kind of response.

e.g. RTD for measurement of temperature has a range of -200`c to 800`c.

Resolution: Resolution is an important specification for selection of sensors.


The higher the resolution, better the precision. When the accretion is zero
to, it is called the threshold.

Provide the smallest changes in the input that a sensor is able to sense.

Precision: It is the capacity of a measuring instrument to give the same


reading when repetitively measuring the same quantity under the same
prescribed conditions.

It implies agreement between successive readings, NOT closeness to the


true value. It is related to the variance of a set of measurements.
It is a necessary but not sufficient condition for accuracy.

Internet of Things And 10


Programming
Sensitivity: Sensitivity indicates the ratio of incremental change in the
response of the system with respect to incremental change in input
parameters. It can be found from the slope of the output characteristics
curve of a sensor. It is the smallest amount of difference in quantity that will
change the instrument’s reading.

Linearity: The deviation of the sensor value curve from a particularly


straight line. Linearity is determined by the calibration curve. The static
calibration curve plots the output amplitude versus the input amplitude
under static conditions.

A curve’s slope resemblance to a straight line describes linearity.

Drift: The difference in the measurement of the sensor from a specific


reading when kept at that value for a long period of time.

Repeatability: The deviation between measurements in a sequence under


the same conditions. The measurements have to be made under a short
enough time duration so as not to allow significant long-term drift.

Zero-order system: The output shows a response to the input signal with no
delay. It does not include energy-storing elements.

Ex. potentiometer measure, linear and rotary displacements.

First-order system: When the output approaches its final value


gradually. Consists of an energy storage and dissipation
element.
Second-order system: Complex output response. The output response of the
sensor oscillates before steady state.

The response of the sensor depends on the magnitude of the direction and
orientation of input parameter. Example – Accelerometer, gyroscope,
magnetic field and motion detector sensors.

Types of sensors –

1.Electrical sensor :

Electrical proximity sensors may be contact or non contact.

Internet of Things And 11


Programming
Simple contact sensors operate by making the sensor and the component
complete an electrical circuit.

Non- contact electrical proximity sensors rely on the electrical principles


of either induction for detecting metals or capacitance for detecting non
metals as well.

2.Light sensor:

Light sensor is also known as photo sensors and one of the important
sensor. Light dependent resistor or LDR is a simple light sensor
available today.
The property of LDR is that its resistance is inversely proportional to the
intensity of the ambient light i.e when the intensity of light increases, it’s
resistance decreases and vise versa.

3.Touch sensor:

Detection of something like a touch of finger or a stylus is known as


touch sensor. It’s name suggests that detection of something.

They are classified into two types:

4.Resistive type

5.Capacitive type

Today almost all modern touch sensors are of capacitive


types. Because they are more accurate and have better
signal to noise ratio.

6.Range sensing:

Range sensing concerns detecting how near or far a component is from the
sensing position, although they can also be used as proximity sensors.

Internet of Things And 12


Programming
Distance or range sensors use non-contact analog techniques. Short range
sensing, between a few millimetres and a few hundred millimetres is carried
out using electrical capacitance, inductance and magnetic technique.

Longer range sensing is carried out using transmitted energy waves of


various types eg radio waves, sound waves and lasers.

7.Mechanical sensor:

Any suitable mechanical / electrical switch may be adopted but because a


certain amount of force is required to operate a mechanical switch it is
common to use micro- switches.

8.Pneumatic sensor:

These proximity sensors operate by breaking or disturbing an air flow.

The pneumatic proximity sensor is an example of a contact type sensor.


These cannot be used where light components may be blown away.

9.Optical sensor:

In there simplest form, optical proximity sensors operate by breaking a light


beam which falls onto a light sensitive device such as a photocell. These are
examples of non contact sensors. Care must be exercised with the lighting
environment of these sensors for example optical sensors can be blinded by
flashes from arc welding processes, airborne dust and smoke clouds may
impede light transmission etc.

10. Speed Sensor:

Sensor used for detecting the speed of any object or vehicle which is in
motion is known as speed sensor .For example – Wind Speed
Sensors, Speedometer ,UDAR ,Ground Speed Radar .

Internet of Things And 13


Programming
11. Temperature Sensor:

Devices which monitors and tracks the temperature and gives


temperature’s measurement as an electrical signal are termed as
temperature sensors .These electrical signals will be in the form of voltage
and is directly proportional to the temperature measurement .

12. PIR Sensor:

PIR stands for passive infrared sensor and it is an electronic sensor that is
used for the tracking and measurement of infrared (IR) light radiating from
objects in its field of view and is also known as Pyroelectric sensor .It is
mainly used for detecting human motion and movement detection .

13. Ultrasonic Sensor:

The principle of ultrasonic sensor is similar to the working principle of


SONAR or RADAR in which the interpretation of echoes from radio or sound
waves to evaluate the attributes of a target by generating the high
frequency sound waves .

Internet of Things And 14


Programming
SOFTWARE
IoT software addresses its key areas of networking and action
through platforms, embedded systems, partner systems, and
middleware. These individual and master applications are
responsible for data collection, device integration, real-time
analytics, and application and process extension within the IoT
network. They exploit integration with critical business systems
(e.g., ordering systems, robotics, scheduling, and more) in the
execution of related tasks.

1.Device Firmware

Firmware is the low-level software embedded in IoT devices that


controls their hardware components. It’s responsible for basic
operations like sensor readings, device control, and
communication with other devices. Firmware needs to be
lightweight and efficient due to the limited resources on many IoT
devices.

2.IoT Operating Systems

Some IoT devices run specialized operating systems designed for


resource- constrained environments. Examples include:

 RIOT OS: An open-source operating system for IoT devices


that is small, efficient, and supports multi-threading.
 Contiki OS: Another open-source OS optimized for low-
power wireless devices, supporting low-power networking.
 Zephyr OS: A scalable real-time operating system that
supports a wide range of IoT devices and includes a robust
set of features for connectivity and security.

3.Middleware

Internet of Things And 15


Programming
Middleware in IoT serves as an intermediary layer that helps
manage the communication and data exchange between devices
and applications. It can handle tasks such as:

 Data Aggregation: Collecting and combining data from


multiple devices.
 Data Transformation: Converting data into a format
suitable for analysis or storage.
 Message Routing: Directing messages between devices
and applications.

4.Communication Protocols

IoT devices use various communication protocols to exchange


data. Some of the common ones include:

 MQTT (Message Queuing Telemetry Transport): A


lightweight messaging protocol designed for low-bandwidth,
high-latency networks.
 CoAP (Constrained Application Protocol): A protocol
designed for simple, constrained devices and networks.
 HTTP/HTTPS: Standard web protocols that are also used in
many IoT applications, especially for cloud-based
interactions.

5.Cloud Platforms

Cloud platforms provide a centralized location for managing,


processing, and storing IoT data. They offer services such as:

 Data Storage and Analysis: Storing large volumes of data


and performing complex analytics.
 Device Management: Monitoring and updating the
software on IoT devices.

Internet of Things And 16


Programming
 Scalability: Handling the varying load of data and device
interactions.

Examples of popular IoT cloud platforms include AWS IoT, Google


Cloud IoT, and Microsoft Azure IoT.

6.Edge Computing

Edge computing involves processing data closer to the source,


rather than sending it all to the cloud. This can reduce latency
and bandwidth usage. Edge software often handles tasks like real-
time data processing, analytics, and decision-making directly on
the device or on local servers.

7.Security Software

Security is a critical concern in IoT, as these devices can be


vulnerable to various types of attacks. Security software for IoT
devices includes:

 Encryption: Protecting data transmitted between devices


and the cloud.
 Authentication and Authorization: Ensuring that only
authorized users and devices can access or control the
system.
 Intrusion Detection Systems: Monitoring for suspicious
activity and potential breaches.

8.Application Software

Finally, application software provides the interface through which


users interact with IoT systems. This can include mobile apps,
web dashboards, and desktop applications that allow users to
monitor, control, and analyze IoT devices

Internet of Things And 17


Programming
ARDIUNO
Arduino (/ɑːrˈdwiːnoʊ/) is an Italian open-source
hardware and software company, project, and user community
that designs and manufactures single-board microcontrollers and
microcontroller kits for building digital devices. Its hardware
products are licensed under a CC BY-SA license, while the
software is licensed under the GNU Lesser General Public
License (LGPL) or the GNU General Public
License (GPL),[1] permitting the manufacture of Arduino boards
and software distribution by anyone. Arduino boards are available
commercially from the official website or through authorized
distributors.[2]
Arduino board designs use a variety of microprocessors and
controllers. The boards are equipped with sets of digital and
analog input/output (I/O) pins that may be interfaced to
various expansion boards ('shields') or breadboards (for
prototyping) and other circuits. The boards feature serial
communications interfaces, including Universal Serial Bus (USB)
on some models, which are also used for loading programs. The
microcontrollers can be programmed using the C and C++
programming languages (Embedded C), using a standard API
which is also known as the Arduino Programming Language,
inspired by the Processing language and used with a modified
version of the Processing IDE. In addition to using traditional
compiler toolchains, the Arduino project provides an integrated
development environment (IDE) and a command line tool
developed in Go.
The Arduino project began in 2005 as a tool for students at the
Interaction Design Institute Ivrea, Italy,[3] aiming to provide a low-
cost and easy way for novices and professionals to create devices
that interact with their environment using sensors and actuators.
Common examples of such devices intended for beginner
hobbyists include simple robots, thermostats, and motion
detectors.
The name Arduino comes from a bar in Ivrea, Italy, where some of
the project's founders used to meet. The bar was named after
Arduin of Ivrea,
Internet of Things And 18
Programming
who was the margrave of the March of Ivrea and King of Italy from
1002 to 1014.[4]
The Arduino project was started at the Interaction Design
Institute Ivrea (IDII) in Ivrea, Italy.[3] At that time, the students
used a BASIC Stamp microcontroller at a cost of $50. In 2004,
Hernando Barragán created the development platform Wiring as a
Master's thesis project at IDII, under the supervision of Massimo
Banzi and Casey Reas. Casey Reas is known for co-creating, with
Ben Fry, the Processing development platform. The project goal
was to create simple, low cost tools for creating digital projects by
non-engineers. The Wiring platform consisted of a printed
circuit board (PCB) with an ATmega128 microcontroller, an IDE
based on Processing and library functions to easily program the
microcontroller.[5] In 2005, Massimo Banzi, with David Mellis,
another IDII student, and David Cuartielles, extended Wiring by
adding support for the cheaper ATmega8 microcontroller. The
new project, forked from Wiring, was called Arduino.[5]
The initial Arduino core team consisted of Massimo Banzi, David
Cuartielles, Tom Igoe, Gianluca Martino, and David Mellis.[3]
Following the completion of the platform, lighter and less
expensive versions were distributed in the open-source
community. It was estimated in mid-2011 that over 300,000
official Arduinos had been commercially produced,[6] and in 2013
that 700,000 official boards were in users' hands.[7]

Official boards
Further information: List of Arduino boards and compatible systems
The original Arduino hardware was manufactured by the Italian
company Smart Projects.[37] Some Arduino-branded boards have
been designed by the American companies SparkFun Electronics
and Adafruit Industries.[38] As of 2016, 17 versions of the
Arduino hardware have been commercially produced.

Internet of Things And 19


Programming
Arduino Arduino
RS232[39] Diecimila[40]
(male pins)

Arduino Arduino Uno R2[42]


Duemilanove[41] [43]
(rev 2009b)

Arduino Uno SMD R3[44] Arduino Leonardo[45]

Internet of Things And 20


Programming
Arduino Micro Arduino Pro Micro
(ATmega32U4) (ATmega32U4)

Arduino Pro[46] Arduino


Mega[47] (No USB)

Arduino
Nano[48] (DIP-
30 footprint)

Internet of Things And 21


Programming
PROGRAMMING
The initial step to start with Arduino is the IDE download and

installation. Let's discuss the basics to start with Arduino

programming.

Brackets

There are two types of brackets used in the Arduino coding, which
are listed below:

o Parentheses ( )
o Curly Brackets { }

Parentheses ( )

The parentheses brackets are the group of the arguments, such


as method, function, or a code statement. These are also used to
group the math equations.

Curly Brackets { }

The statements in the code are enclosed in the curly brackets. We


always require closed curly brackets to match the open curly
bracket in the code or sketch.

Open curly bracket- ' { '

Closed curly bracket - ' }

' Line Comment

There are two types of line comments, which are listed below:

o Single line comment


o Multi-line comment

Internet of Things And 22


Programming
// Single line comment

The text that is written after the two forward slashes are
considered as a single line comment. The compiler ignores the
code written after the two forward slashes. The comment will not
be displayed in the output. Such text is specified for a better
understanding of the code or for the explanation of any code
statement.

The // (two forward slashes) are also used to ignore some extra
lines of code without deleting it.

/ * Multi - line comment */

The Multi-line comment is written to group the information for


clear understanding. It starts with the single forward slash and an
asterisk symbol (/ *). It also ends with the / *. It is commonly used
to write the larger text. It is a comment, which is also ignored by
the compiler.

Coding Screen

The coding screen is divided into two blocks. The setup is


considered as the preparation block, while the loop is considered
as the execution block. It is shown below:

Internet of Things And 23


Programming
The set of statements in the setup and loop blocks are enclosed
with the curly brackets. We can write multiple statements
depending on the coding requirements for a particular project.

void setup ( )
{
Coding statement 1;
Coding statement 2;
.
.
.
Coding statement n;
}
void loop ( )
{
Coding statement 1;
Coding statement 2;
.
.
.
Coding statement n;
}

What is Setup? What type of code is written in the setup block?

It contains an initial part of the code to be executed. The pin


modes, libraries, variables, etc., are initialized in the setup
section. It is executed only once during the uploading of the
program and after reset or power up of the Arduino board.

Zero setup () resides at the top of each sketch. As soon as the


program starts running, the code inside the curly bracket is
executed in the setup and it executes only once.

Internet of Things And 24


Programming
What is Loop? What type of code is written in the Loop block?

The loop contains statements that are executed repeatedly. The


section of code inside the curly brackets is repeated depending on
the value of variables.

Time in Arduino

The time in Arduino programming is measured in a

millisecond. Where, 1 sec = 1000 milliseconds

We can adjust the timing according to the milliseconds.

For example, for a 5-second delay, the time displayed will be


5000 milliseconds.

Example:

Let's consider a simple LED blink

example. The steps to open such

example are:

1. Click on the File button, which is present on the menu bar.


2. Click on the Examples.
3. Click on the Basics option and click on the Blink

The example will reopen in a new window, as shown below:

Internet of Things And 25


Programming
o The void setup () would include pinMode as the main function.

pinMode ( )

The specific pin number is set as the INPUT or OUTPUT in the pinMode
() function.

The Syntax is: pinMode (pin, mode)

Where,

pin: It is the pin number. We can select the pin number according to
the requirements.

Mode: We can set the mode as INPUT or OUTPUT according to


the corresponding pin number.

Let' understand the pinMode with an example.

Example: We want to set the 12 pin number as the

output pin. Code:

pinMode (12, OUTPUT);

Why is it recommended to set the mode of pins as OUTPUT?

The OUTPUT mode of a specific pin number provides a


considerable amount of current to other circuits, which is enough
to run a sensor or to light the LED brightly. The output state of a
pin is considered as the low- impedance state.

The high current and short circuit of a pin can damage the ATmel
chip. So, it is recommended to set the mode as OUTPUT.

Can we set the pinMode as INPUT?

Internet of Things And 26


Programming
The digitalWrite () will disable the LOW during the INPUT mode.
The output pin will be considered as HIGH.

We can use the INPUT mode to use the external pull-down


resistor. We are required to set the pinMode as INPUT_PULLUP. It
is used to reverse the nature of the INPUT mode.

The sufficient amount of current is provided by the pull-up mode


to dimly light an LED, which is connected to the pin in the INPUT
mode. If the LED is working dimly, it means this condition is
working out.

Due to this, it is recommended to set the pin in OUTPUT mode.

o The void loop () would include digitalWrite( ) and delay


( ) as the main function.

digitalWrite( )

The digitalWrite ( ) function is used to set the value of a pin as


HIGH or LOW.

Where,

HIGH: It sets the value of the voltage. For the 5V board, it will set
the value of 5V, while for 3.3V, it will set the value of 3.3V.

LOW: It sets the value = 0 (GND).

If we do not set the pinMode as OUTPUT, the LED may light

dim. The syntax is: digitalWrite( pin, value HIGH/LOW)

pin: We can specify the pin number or the declared

variable. Let's understand with an example.

Example:

Internet of Things And 27


Programming
1. digitalWrite (13, HIGH);
2. digitalWrite (13, LOW);

The HIGH will ON the LED and LOW will OFF the LED connected to
pin number 13.

What is the difference between digitalRead () and digitalWrite


()?

The digitalRead () function will read the HIGH/LOW value from the
digital pin, and the digitalWrite () function is used to set the
HIGH/LOW value of the digital pin.

delay ( )

The delay () function is a blocking function to pause a program


from doing a task during the specified duration in milliseconds.

For example, - delay (2000)

Where, 1 sec =

1000millisecond

Hence, it will provide a delay of 2

seconds. Code:

digitalWrite (13, HIGH);


delay (2000);
digitalWrite (13, LOW);
delay (1000);

Here, the LED connected to pin number 13 will be ON for 2


seconds and OFF for 1 second. The task will repeatedly execute as
it is in the void loop ().

We can set the duration according to our choice or project


requirements.

Internet of Things And 28


Programming
Example: To light the LED connected to pin number 13. We want to
ON the LED for 4 seconds and OFF the LED for 1.5 seconds.

Code:

void setup ()
{
pinMode ( 13, OUTPUT); // to set the OUTPUT mode of pin number 13.
}
void loop ()
{
digitalWrite (13, HIGH);
delay (4000); // 4 seconds = 4 x 1000 milliseconds
digitalWrite (13, LOW);
delay (1500); // 1.5 seconds = 1.5 x 1000 milliseconds
}

Internet of Things And 29


Programming
EXAMPLE PROJECT
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.

Internet of Things And 30


Programming
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.

Internet of Things And 31


Programming
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 setup() { // initialize digital pin 13 as an output.
pinMode(2, OUTPUT);}
// the loop function runs over and over again forever

Internet of Things And 32


Programming
void loop() {
digitalWrite(2, HIGH); // turn the LED on (HIGH is the voltage
level) delay(1000); // wait for a second
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.

Internet of Things And 33


Programming
CONCLUSION
The Internet of Things (IoT) represents a significant technological
advancement that continues to shape the future of our
interconnected world. By enabling everyday objects to
communicate, share data, and perform intelligent actions, IoT has
transformed various industries, including healthcare, agriculture,
manufacturing, and smart cities. Throughout this seminar report,
we have explored the fundamental components, technologies,
and programming paradigms that drive the IoT ecosystem,
highlighting the crucial role of programming in enabling IoT
devices and applications to function effectively and efficiently.

Programming is the backbone of IoT development, providing the


necessary instructions for devices to sense, process, and act upon
data. From low- level programming of microcontrollers and
embedded systems to high- level application development and
data analytics, programming languages such as C, C++, Python,
and JavaScript play a pivotal role in building robust, scalable, and
secure IoT solutions. The choice of programming language and
tools depends on various factors, including the specific application
requirements, hardware constraints, and desired functionality,
underscoring the need for versatile and adaptable programming
skills in IoT development.

However, the rapid proliferation of IoT devices has also introduced


several challenges that need to be addressed to realize the full
potential of this technology. Security remains a major concern, as
the increasing number of connected devices presents more
opportunities for cyberattacks and data breaches. Ensuring the
privacy and safety of users is paramount, necessitating the
implementation of robust security measures, such as encryption,
authentication, and regular software updates. Moreover, the
scalability and interoperability of IoT systems are critical for
managing the growing number of devices and ensuring seamless
communication across different platforms and protocols.
Adhering to open standards and

Internet of Things And 34


Programming
developing flexible, scalable architectures will be essential for the
future growth and sustainability of IoT ecosystems.

Looking ahead, the future of IoT and programming is filled with


exciting possibilities. Emerging technologies such as artificial
intelligence (AI), machine learning, and edge computing are
poised to enhance the capabilities of IoT systems, enabling more
intelligent and autonomous operations. As IoT continues to
evolve, new programming paradigms and tools will be needed to
address the unique challenges and opportunities presented by
this dynamic field. The integration of IoT with AI and data
analytics will drive further innovation, creating smarter, more
responsive systems that can anticipate and adapt to changing
conditions in real-time.

In conclusion, the Internet of Things and programming are closely


intertwined, each driving the other forward in a continuous cycle
of innovation and development. As we continue to explore and
expand the possibilities of IoT, the importance of programming as
a foundational skill cannot be overstated. By embracing new
technologies, adhering to best practices, and fostering a culture
of security and interoperability, we can unlock the full potential of
IoT, creating a more connected, efficient, and intelligent world for
all.

Internet of Things And 35


Programming
REFERENCES

Internet of Things And 36


Programming

You might also like