0% found this document useful (0 votes)
11 views42 pages

Arduino

The document is an internship report by K A Mohammed Yusuf, a student of Electronics and Communication Engineering at HKBK College of Engineering, detailing his experience in the 'Departmental Lab-IOT' during the academic year 2022-2023. It outlines the objectives, outcomes, and skills acquired during the internship, including the design and development of smart home devices using Arduino and IoT technologies. The report also includes acknowledgments, a declaration of originality, and an overview of basic electronic devices and Arduino programming.

Uploaded by

infoezyintern
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views42 pages

Arduino

The document is an internship report by K A Mohammed Yusuf, a student of Electronics and Communication Engineering at HKBK College of Engineering, detailing his experience in the 'Departmental Lab-IOT' during the academic year 2022-2023. It outlines the objectives, outcomes, and skills acquired during the internship, including the design and development of smart home devices using Arduino and IoT technologies. The report also includes acknowledgments, a declaration of originality, and an overview of basic electronic devices and Arduino programming.

Uploaded by

infoezyintern
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

lOMoARcPSD|57908132

Yusuf Final Internship Report

Electronics and Communication Engineering (HKBK College of Engineering)

Scan to open on Studocu

Studocu is not sponsored or endorsed by any college or university


Downloaded by om Raj ([Link]@[Link])
lOMoARcPSD|57908132

VISVESVARAYA TECHNOLOGICAL UNIVERSITY


JNANASANGAMA, BELAGAVI – 590018

Internship Report (21INT49)


On

“DEPARTMENTAL LAB-IOT”
Submitted in partial fulfillment for the award of degree of

Bachelor of Engineering
In
Electronics and Communication Engineering

For the Academic Year 2022-2023

Submitted by
K A MOHAMED YUSUF(USN: 1HK21EC038)

IV SEMESTER
UNDER THE GUIDANCE OF
External Guide Internal Guide
Prof. Yogananda Raj Urs KH Dr. Abdul Azeez
Assistant Professor Associate Professor
Dept of ECE Dept of ECE

Intra Institutional Internship


Carried Out

HKBK COLLEGE OF ENGINEERING, BANGALORE-560045


DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

HKBK COLLEGE OF ENGINEERING, BANGALORE-560045


DEPARTMENT OF ELECTRONICS AND COMMUNICATION

CERTIFICATE OF INTERNSHIP

This is to certify that this internship report titled “DEPARTMENTAL LAB-IOT” carried
out by K A MOHAMED YUSUF bearing USN 1HK21EC063 a bonafide student of HKBK
College of Engineering, in partial fulfillment for the award of Bachelor of Engineering
Degree in Electronics and Communication Engineering of the Visvesvaraya Technological
University, Belagavi during the year 2022-23 is a genuine curriculum program.
Intern has successfully completed his/her training from 11 th October 2022 to 31 st October,
2022. During the internship, the intern maintained a professional demeanor and has gained
several skills and competencies.
It is certified that all the corrections/suggestions indicated before the assessment and evaluation
have been incorporated by the intern in this internship report. The internship report has been
approved as it satisfies the academic requirements prescribed by the relevant VTU notifications
and institute for the award of B.E degree.

[Link] Raj Urs [Link] Azeez Dr. Latha R Dr. Tabassum Ara
KH
External Guide Internal Guide HOD, Principal,
Department of ECE, Department of ECE, Department of ECE, HKBKCE, Bengaluru
HKBKCE HKBKCE HKBKCE, Bengaluru

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

HKBK COLLEGE OF ENGINEERING, BANGALORE-560045


DEPARTMENT OF ELECTRONICS AND COMMUNICATION

DECLARATION
I,K A MOHAMMED YUSUF bearing USN No. 1HK21EC063 student of IV semester,
B.E degree in Electronics and Communication Engineering declare that this Intra
Institutional InternshipProgram titled “Departmental Lab-IOT’’ is original work carried
out by me, the undersigned in the college campus at after endorsement and authorization
from competentauthorities of HKBK College of Engineering, in partial fulfillment of the
curriculum requirements of prescribed by Visvesvaraya Technological University ,
Belagavi in the 2022 B.E Degree Choice Based Credit System Scheme.

The content in this report is not submitted to any other university partially or wholly for
the award of any other degree

K A MOHAMMED YUSUF
USN: 1HK21EC063
Date: 09/08/2023
IV Sem, B.E
Place: Bengaluru
Electronics and Communication Engineering

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

ACKNOWLEDGEMENT
The euphoria that accompanies the acquisition of vocational skills by professing
internship program and compiling internship report would be complete only by acknowledgingthe
governing bodies and the personnel, who by their supervision steered and crowned out myeffort
with success.
I am grateful to the Chairman, Mr. C. M. Ibrahim, for having provided me an opportunity
to emerge as a responsible citizen with Professional Engineering Skills and moral ethics.

I am grateful to the Director, Mr. C. M. Faiz Mohammed, for having provided me with
excellent facilities in the college during my course.

I would like to express my heartfelt thanks to our Principal, Dr. Tabassum Ara, HKBK
College of Engineering for her enduring encouragement and support to the students inacademic
and co-curricular pursuits

I would like to express my genuine thanks to our Head of Department of Electronics and
Communication Engineering, Dr. Latha Rajagopalan for facilitating the internshipprogram and
her support in our academic and co-curricular activities.

I would like to extend my profound thanks and admiration to my Prof Yogananda Raj
Urs KH, Department of ECE, for his constant guidance and critical comments through the
course of the internship

I thank my Guide Dr. Abdul Azeez, Assistant Professor for his valuable guidance,
suggestions and encouragement during the course of my internship.

I thank my internship coordinator Dr. Abdul Azeez, Associate Professor for his constant
guidance, support and critical comments during the course of my internship.

K A MOHAMMED YUSUF
1HK21EC063

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

Internship Objectives:

1. Expose Technical students to the industrial environment, which cannot be simulated in the
classroom and hence create competent professionals in the industry.
2. Provide possible opportunities to learn, understand and sharpen the real-time
technical/managerial skills required at the job.
3. Get exposed to the current technological developments relevant to the subject area of training.
4. Use the experience gained from the industrial internship in discussions held in the classrooms.
5. Create conditions conducive to the quest for knowledge and its applicability on the job.
6. Learn to apply technical knowledge in real industrial situations.
7. Gain experience in writing reports in technical works/projects.
8. Expose students to the engineer’s responsibilities and ethics.
9. Familiarize with various materials, processes, products, and applications along with relevant
aspects of quality control and safety measures.
10. Promote academic, career, and/or personal development.
11. Expose the students to future employers.
12. Make students available to industry for employment.
13. Understand the psychology of the workers and their habits, attitudes, and approach to
problem-solving.
14. Understand the social, economic, and administrative considerations that influence the
working environment of industrial organizations.

Outcomes:
1. Build and enhance industrial relations.
2. Make the placement process easier.
3. Improve institutional credibility & branding.
4. Improve the teaching-learning process.
5. Expose of Staff to Industrial process.
6. Serve human

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

INSTITUTE MISSION & VISION

MISSION
[Link] achieve academic excellence through in-depth knowledge in science, engineering and
technology through dedication to duty, innovation in teaching and faith in human values.
[Link] enable our students to develop into outstanding professionals with high ethicalstandards to
face the challenges of the 21st century.
[Link] provide educational opportunities to the deprived and weaker section of thesociety, to
uplift their socio-economic status.

VISION
To empower students through wholesome education and enable the students to developinto highly qualified
and trained professionals with ethics and emerge as responsible citizens with broad outlook to build a
vibrant nation

DEPARTMENT MISSION & VISION


[Link] lay a strong foundation in theoretical concepts and experiential learning in thefield of
artificial intelligence, machine learning, and allied fields.
[Link] inculcate self-learning abilities, team spirit, and professional ethics among thestudents
to emerge as valued entrepreneurs and serve society.
[Link] promote innovation and entrepreneurship ideas among students to be job creatorsin future.

To prepare students to serve society with a holistic approach and participate in nation-building.

HKBK COLLEGE OF ENGINEERING


Opp Manyata Tech Park, Nagawara, Bangalore-560045, Karnataka
Email: info@[Link]

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

ACHIEVEMENTS

The institute is accredited by the National Board of Accreditation and National Assessment and
Accreditation Council and approved by UGC.

Computer Science & Engineering and Information Science & Engineering provided additional certificate
courses to students to improve their employability.

HKBK College of Engineering opened its Technology Incubator to promote start-ups and
entrepreneurship in young talents.

HKBK College of Engineering has established strong relations with industry leaders to provide the
students with both knowledge and an exceptional career.

The highest CTC offered in 2019 was 14.4 lakhs and the highest internship stipend was 31,000. Overall,
more than 91% of the students get placed at various firms.

Over the years, HKBK College of Engineering has seen an increase in start-ups with over 23 start-ups
being fully functional.
Accredited by NBA (National Board of Accreditation) for quality education and infrastructure.

Industry Collaboration:
Collaborations with prominent industries and organizations to enhance practical exposure and
employability of students.
Tie-ups with leading IT companies for internships, workshops, and placement opportunities.

Quality Faculty:
The college boasts a diverse and experienced faculty team, with a mix of industry experts and
academicians.

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

ABSTRACT

The Internet of Things (IoT) is a network of physical objects that can communicate
and interact with each other through the internet. Arduino is an open-source platform
that allows users to create electronic projects using hardware and software
components. In this internship, the intern will learn how to use Arduino to design and
develop smart home devices that can monitor and control various aspects of the home
environment, such as temperature, humidity, light, motion, sound, etc. The intern will
also learn how to use various sensors, actuators, and communication modules to
connect the devices to the internet and cloud services. The intern will work on a
project that involves creating a prototype of a smart home device using Arduino and
IoT technologies.

The project will require the intern to apply the skills and knowledge acquired during
the internship, such as circuit design, programming, debugging, testing,
documentation, etc. The intern will also present the project to the mentor and other
interns at the end of the internship. The internship will provide the intern with
valuable experience and exposure to the field of IoT and Arduino. The intern will also
develop problem-solving, creativity, teamwork, and communication skills. The
internship will be a great opportunity for the intern to explore their interest and
passion in IoT and Arduino.

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

TABLE OF CONTENT
CONTENT [Link]

CHAPTER 1:
INTRODUCTIONINTRODUCTION OF BASIC ELECTRONIC DEVICES……......12
1.1 Resistors………………………………………………………………………….12
1.2 Capacitor…………………………………………………………………………13
1.3 Diode……………………………………………………………………………..14
1.4 Transistor ………………………………………………………………………...15
1.5 Breadboard ………………………………………………………………………15

CHAPTER 2: OVERVIEW OF ARDUINO UNO………………….………………..…..16


2.1 Microcontrollers…………………………………………………………….18
2.2 ATmega168…………………………………………………………………18
2.3 Digital pins………………………………………………………………….18
2.4 Analog pins…………………………………………………………………19
2.5 Power pins…………………………………………………………………..19
2.6 Other pins………………………………………………………………...…19

CHAPTER 3: Basics of Arduino programming…………………………………………...20


3.1 Variable………………………………………………………………………20
3.2 Input-Output Direction……………………………………………………….20
3.3 Read write instruction….…………………………………………………….20
3.4 Delay…………………………………………………………………………21
3.5 Arduino Coding Basics………………………………………………………21
3.6 Line Comment……………………………………………………………….22
3.7 Coding scree………………………………………………………………….22

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

CHAPTER 4: Experiments in analog electronics29


4.1 Experiment 1- Verifying Ohm’s law………………………………………...28
4.2 Experiment 1- Verifying Ohm’s law…………………………………...……29
4.3 Experiment 1- Verifying Ohm’s law …………………………………….....30

CHAPTER 5: Experiments using Arduino uno…………………………………….………... 32


5.1 Turning On-Off an LED using Arduino……………………………………. 32
5.2 Controlling LED using Push Button Switch…………………………………33
5.3 Measuring Temperature and Humidity………………………………………33
5.4 Water Sensor…………………………………………………………………34
5.5 Gas sensor……………………………………………………………………34

CHAPTER 6: programs on mini project using Arduino…………………………………37


6.1 Water Sensor…………………………………………………..……………..37
6.2 Controlling LED using Push Button Switch………………………………… 38
6.3 Measuring Temperatue and Humidity……………………………………….38
6.4 Water sensor………………………………………………………………....39
6.5 Gas sesor……………………………………………………………………..40

CONCLUSION…………………..………………………………………………………….41

REFERENCES……………………………………………………………………………. .42

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

LIST OF EXHIBITS-FIGURES

Figure List of figures Page No


1.1 Resistor 12
1.2 Resistor color code 12
1.3 Capacitor 13
1.4 Capacitor value 13
1.5 calculating capacitor value 13
1.6 Terminal of capacitor 14
1.7 Diode 14
1.8 Transistor 15
1.9 Breadboard 15
2.1 Arduino UNO 16
2.2 Pins of Arduino UNO 17
3.1 Arduino program interface 23
3.2 Blinking of LED program 25
4.1 LDR Circuit 29
4.2 LDR Characteristics 29
4.3 LDR controlled transistor circuit 30
4.4 Photodiode circuit 30
5.1 Blinking LED 32
5.2 LED control using Push button. 33
5.3 Measuring Temperature and Humidity 34
using Arduino UNO
5.4 Water sensor Circuit 34
5.5 Gas Sensor Circuit 35

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

Departmental lab -IOT

CHAPTER 1

INTRODUCTION OF BASIC ELECTRONIC DEVICES

The importance of knowing the required amount of current flow and voltage in any electronic device
is very essential.
We learnt the significance of Ohm’s law by rigging up the electronic circuit on a breadboard of LED
without resistor and with resistor, where we used 9V battery power supply.
The most basic electronic components are:

1.1 Resistors
Resistor is used to limit the current flow in an electronic circuit. It is used based on its band values
and circuit design requirement.

Fig 1.1: Resistor

Chart of Resistor Color Code:

Fig 1.2: Resistor color code

Dept Of ECE, HKBKCE Pg No: 12 of 41 2022-23

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

Departmental lab -IOT

1.2 Capacitor
Capacitor is used to store the voltage value in it. It is used in all the major circuit applications.

Fig 1.3: Capacitor

Chart of Capacitor value

Fig 1.4: capacitor value

Fig 1.5 : calculating capacitor value (image source:

Dept Of ECE, HKBKCE Pg No: 13 of 41 2022-23

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

Departmental lab -IOT

Fig1.6: Terminal of capacitor


1.3 Diode
Diode is the basic current conducting device in the form of P-N junction. Two terminals are there:
Anode (+) and Cathode (-).

Fig 1.7: Diode


1.4 Transistor
Transistor is a three-terminal device. Base (B), Collector(C) and Emitter(E). It is used as a
amplifying device.

Fig 1.8: Transistor

Dept Of ECE, HKBKCE Pg No: 14 of 41 2022-23

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

Departmental lab -IOT

Measuring Devices:
We have used the following major electronic instruments for electronic circuit output measurements:
1. Ammeter
2. Voltmeter
3. Cathode Ray Oscilloscope (CRO)
1.5 BREADBOARD:
To build and test the electronic circuits we have used the BREADBOARD as alias to PCB(Printed
Circuit Board).

Fig 1.9: Breadboard

Dept Of ECE, HKBKCE Pg No: 15 of 41 2022-23

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

Departmental lab -IOT

CHAPTER 2
OVERVIEW OF ARDUINO UNO
Arduino is a student friendly, cost effective open-source platform for electronic circuit designing and
to implement hobby to graduation project. It is easy-to-use hardware and software gateway.
Arduino has both the Software IDE (Integrated Development Environment) and Hardware board of
various types. We have used Arduino UNO hardware board for our first programming based
electronic design.

Fig 2.1: Arduino UNO

Arduino Uno is a microcontroller board. It uses the ATmega328 microcontroller. There are Analog
Input pins, Digital Input pins, Digital Output pins.
1. 6 Analog input pins,
2. 14 Digital Input-Output pins.
3. Among the Digital input-output pins 6 can be used as PWM outputs.
4. It also contains
a. A 16 MHz ceramic resonator,
b. a USB connection,
c. a power jack,
d. an ICSP header and a reset button.

Dept Of ECE, HKBKCE Pg No: 16 of 41 2022-23

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

Departmental lab -IOT

Looking at the board from the top down, this is an outline of what you will see (parts of the board
you might interact with in the course of normal use are highlighted)

Fig 2.2: Pins of Arduino UNO

Starting clockwise from the top center:

 Analog Reference pin (orange)


 Digital Ground (light green)
 Digital Pins 2-13 (green)
 Digital Pins 0-1/Serial In/Out - TX/RX (dark green) - These pins cannot be used for digital i/o
(digitalRead and digitalWrite) if you are also using serial communication (e.g. [Link]).
 Reset Button - S1 (dark blue)
 In-circuit Serial Programmer (blue-green)
 Analog In Pins 0-5 (light blue)
 Power and Ground Pins (power: orange, grounds: light orange)
 External Power Supply In (9-12VDC) - X1 (pink)
 Toggles External Power and USB Power (place jumper on two pins closest to desired supply) -
SV1 (purple)

Dept Of ECE, HKBKCE Pg No: 17 of 41 2022-23

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

Departmental lab -IOT

 USB (used for uploading sketches to the board and for serial communication between the board
and the computer; can be used to power the board) (yellow)

2.1 Microcontrollers
ATmega328P (used on most recent boards)

 Digital I/O Pins: 14 (of which 6 provide PWM output)


 Analog Input Pins: 6 (DIP) or 8 (SMD)
 DC Current per I/O Pin: 40 mA
 Flash Memory: 32 KB
 SRAM: 2 KB
 EEPROM: 1 KB

2.2 ATmega168 (used on most Arduino Diecimila and early Duemilanove)

 Digital I/O Pins: 14 (of which 6 provide PWM output)


 Analog Input Pins: 6 (DIP) or 8 (SMD)
 DC Current per I/O Pin: 40 mA
 Flash Memory 16 KB:
 SRAM: 1 KB
 EEPROM: 512 byteS

2.3 Digital Pins


In addition to the specific functions listed below, the digital pins on an Arduino board can be used
for general purpose input and output via the pinMode(), digitalRead(),
and digitalWrite() commands. Each pin has an internal pull-up resistor which can be turned on and
off using digitalWrite() (w/ a value of HIGH or LOW, respectively) when the pin is configured as
an input. The maximum current per pin is 40 mA.

 Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data. On the
Arduino Diecimila, these pins are connected to the corresponding pins of the FTDI USB-to-TTL
Serial chip. On the Arduino BT, they are connected to the corresponding pins of the WT11
Bluetooth® module. On the Arduino Mini and LilyPad Arduino, they are intended for use with
an external TTL serial module (e.g. the Mini-USB Adapter).

Dept Of ECE, HKBKCE Pg No: 18 of 41 2022-23

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

Departmental lab -IOT

 External Interrupts: 2 and 3. These pins can be configured to trigger an interrupt on a low value,
a rising or falling edge, or a change in value. See the attachInterrupt() function for details.
 PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite() function. On
boards with an ATmega8, PWM output is available only on pins 9, 10, and 11.
 SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication, which,
although provided by the underlying hardware, is not currently included in the Arduino language.
 LED: 13. On the Diecimila and LilyPad, there is a built-in LED connected to digital pin 13. When
the pin is HIGH value, the LED is on, when the pin is LOW, it's off.

2.4 Analog Pins

In addition to the specific functions listed below, the analog input pins support 10-bit analog-to-digital
conversion (ADC) using the analogRead() function. Most of the analog inputs can also be used as digital
pins: analog input 0 as digital pin 14 through analog input 5 as digital pin 19. Analog inputs 6 and 7 (present
on the Mini and BT) cannot be used as digital pins.

 I2C: 4 (SDA) and 5 (SCL). Support I2C (TWI) communication using the Wire library
(documentation on the Wiring website).

2.5 Power Pins

 VIN (sometimes labelled "9V"). The input voltage to the Arduino board when it's using an
external power source (as opposed to 5 volts from the USB connection or other regulated power
source). You can supply voltage through this pin, or, if supplying voltage via the power jack,
access it through this pin. Note that different boards accept different input voltages ranges,
please see the documentation for your board. Also note that the LilyPad has no VIN pin and
accepts only a regulated input..
 3V3. (Diecimila-only) A 3.3 volt supply generated by the on-board FTDI chip.
 GND. Ground pins.

2.6 Other Pins

 AREF. Reference voltage for the analog inputs. Used with analogReference().
 Reset. (Diecimila-only) Bring this line LOW to reset the microcontroller. Typically used to add
a reset button to shields which block the one on the board.

Dept Of ECE, HKBKCE Pg No: 19 of 41 2022-23

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

Departmental lab -IOT

CHAPTER 3
BASICS OF ARDUINO PROGRAMMING
Arduino programming uses ‘C++’ programming syntax.
Initially, the Arduino programming contains two default functions:
1. void setup ( ) { }
2. void loop ( ) { }

3.1 Variable:
Here we learnt the concept of declaring variables for the Arduino UNO input-output pins.
Example: int sensor = A0;
int buzzer = 2;
where sensor and buzzer are variables, sensor variable is applied to the Analog pin A0, buzzer variable
is applied to the Digital pin 2.
3.2 Input-Output Direction:
Syntax:
pinMode(pinNumber, Mode);
Example: pinMode( 2, OUTPUT);
Here,
pinNumber is the Arduino UNO board Input-Output pin number and buzzer variable is defined as
OUTPUT pin.
Mode means the direction for input or output of any particular available pin number or declared
variable.
3.3 Write-Read Instruction:
1. Write Instruction: Write means which gives value to the connected the device from the program.
Example: Output devices like, LED, Buzzer.
Syntax:
digitalWrite(variableName, Value);
Example: digitalWrite(buzzer, HIGH);
Here,
variableName is the name given Input or Output pin number.
Value means the logic 1 (HIGH) or logic 0 (LOW) value.
2. Read Instruction: Read means which takes the value from the external environment through the

Dept Of ECE, HKBKCE Pg No: 20 of 41 2022-23

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

Departmental lab -IOT

connected device. Example: Input Devices like Push button, Keypad, Water Sensor, Gas Sensor,
Temperature Sensor, Humidity Sensor.
Syntax:
digitalRead(variableName, Value);
Example: digitalRead(sensor, LOW);
Here, variableName is the name given Input or Output pin number.
Value means the logic 1 (HIGH) or logic 0 (LOW) value.
3.4 Delay:
Delay means adding pause in between the simultaneous or multiple operations.
Syntax:
delay(Value);
Example: delay(3000);
Here, Value means the time unit in seconds, 1000 means 1second, 500 means 0.5second.
3.5 Arduino Coding Basics
We have already discussed the popular Arduino Boards, Arduino IDEs, and Installation process of the Arduino
software. We learned that Arduino IDE (Integrated Development Environment) allows us to draw the sketch
and upload it to the various Arduino boards using code. The code is written in a simple programming language
similar to C and C++.

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.

Dept Of ECE, HKBKCE Pg No: 21 of 41 2022-23

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

Departmental lab -IOT

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 - ' } '

3.6 Line Comment

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

o Single line comment

o Multi-line comment

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

3.7 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:

Dept Of ECE, HKBKCE Pg No: 22 of 41 2022-23

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

Departmental lab -IOT

Fig 3.1: Arduino program interface

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.

For example:

1. void setup ( )
2. {
3. Coding statement 1;
4. Coding statement 2;
5. .
6. .
7. .
8. Coding statement n;
9. }
10. void loop ( )
11. {

Dept Of ECE, HKBKCE Pg No: 23 of 41 2022-23

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

Departmental lab -IOT

12. Coding statement 1;


13. Coding statement 2;
14. .
15. .
16. .
17. Coding statement n;
18. }

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.

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:

Dept Of ECE, HKBKCE Pg No: 24 of 41 2022-23

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

Departmental lab -IOT

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:

Fig 3.2: blinking of LED Program

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 [Link]'
understand the pinMode with an example.

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

Dept Of ECE, HKBKCE Pg No: 25 of 41 2022-23

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

Departmental lab -IOT

Code:

1. 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?

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.

Dept Of ECE, HKBKCE Pg No: 26 of 41 2022-23

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

Departmental lab -IOT

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:

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:

1. digitalWrite (13, HIGH);


2. delay (2000);
3. digitalWrite (13, LOW);

Dept Of ECE, HKBKCE Pg No: 27 of 41 2022-23

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

Departmental lab -IOT

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

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:

1. void setup ()
2. {
3. pinMode ( 13, OUTPUT); // to set the OUTPUT mode of pin number 13.
4. }
5. void loop ()
6. {
7. digitalWrite (13, HIGH);
8. delay (4000); // 4 seconds = 4 x 1000 milliseconds
9. digitalWrite (13, LOW);
10. delay (1500); // 1.5 seconds = 1.5 x 1000 milliseconds
11. }

Dept Of ECE, HKBKCE Pg No: 28 of 41 2022-23

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

Departmental lab -IOT

CHAPTER 4
EXPERIMENTS IN ANALOG ELECTRONICS
We have performed the below basic analog experiments:
1. Verifying Ohm’s law
2. Light Detection Resistor
3. Photodiode

4.1 Experiment 1- Verifying Ohm’s law:


We used the simple circuit of testing LED brightness glow using a 9V D.C. Battery supply
in two parts.
Components Used: Red LED – 2, Resistor - 100Ω, Resistor -1K Ω, Breadboard and 9V D.C.
Battery.
Working:
In first part, An LED was connected on the Breadboard and we directly connected the LED Anode to
the ‘+’ positive terminal of 9V D.C. Battery and LED Cathode to the ‘−’ negative terminal of 9V
D.C. Battery. As a result, the LED burnt-off due High Power supply to the LED also infinite resistance
value.
In second part, we added a resistor of 100Ω to the circuit. We connected a 100Ω resistor one end to
the LED Anode and the other end of the 100Ω resistor was connected to the ‘+’ positive terminal of
9V D.C. Battery. The LED Cathode was connected to ‘−’ negative terminal 9V D.C.
Battery. As a result, the LED was glowing very brightly.
Also, in the same circuit we removed the 100Ω resistor and replaced it with a 1kΩ resistor. As a
result, the LED was glowing with less brightness.
From these results, we verified the Ohm’s law by analyzing when
1. resistor = ∞ (No resistor) => LED didn’t glow
2. resistor = 1k Ω => LED was glowing with less brightness
3. resistor = 100Ω => LED was glowing with more brightness

Dept Of ECE, HKBKCE Pg No: 29 of 41 2022-23

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

Departmental lab -IOT

4.2 Experiment 2- Light Detection Resistor:


To know the usage of multi-meter (voltmeter, ammeter, Ohm meter), AC Power supply and also
to understand the working principle of Light Dependent Resistor(LDR) we performed this
experiment.
Components Used: Multi-meter, LDR, 40W Bulb.
Circuit Diagram:

Fig 4.1: LDR Circuit


We connected the Bulb as per the circuit diagram, we made the bulb intensity to fall on the LDR
and we varied the intensity of light from less brightness to brightness and to more brightness, from
varying the light intensity, we learnt that, the resistance decreases as the incident light intensity
increases and the resistance increases as the incident light intensity decreases.

Fig 4.2: LDR Characteristics

Applications of LDRs

There are many applications for Light Dependent Resistors. These include:

Lighting switch

The most obvious application for an LDR is to automatically turn on a light at a certain light level.
An example of this could be a street light or a garden light.

Dept Of ECE, HKBKCE Pg No: 30 of 41 2022-23

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

Departmental lab -IOT

Camera shutter control

LDRs can be used to control the shutter speed on a camera. The LDR would be used to measure the
light intensity which then adjusts the camera shutter speed to the appropriate level.

Example - LDR controlled Transistor circuit

Fig 4.3: LDR controlled transistor circuit

The circuit shown above shows a simple way of constructing a circuit that turns on when it goes
dark. In this circuit the LDR and the other Resistor form a simple 'Potential Divider' circuit, where
the centre point of the Potential Divider is fed to the Base of the NPN Transistor. When the light
level decreases, the resistance of the LDR increases. As this resistance increases in relation to the
other Resistor, which has a fixed resistance, it causes the voltage dropped across the LDR to also
increase. When this voltage is large enough (0.7V for a typical NPN Transistor), it will cause the
Transistor to turn on. The value of the fixed resistor will depend on the LDR used, the transistor
used and the supply voltage.

4.3 Experiment -3 : Photodiode


To know the usage of multi-meter (voltmeter, ammeter, Ohm meter), AC Power supply and also to
understand the working principle of Photodiode we performed this experiment.
Components Used: Multi-meter, LDR, 40W Bulb, Photodiode, Resistor -1KΩ
Circuit Diagram:

Dept Of ECE, HKBKCE Pg No: 31 of 41 2022-23

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

Departmental lab -IOT

Fig 4.4: Photodiode Circuit

We connected the circuit as per the circuit diagram and the voltage across the photodiode was kept
constant. We used Room light (Darkness) and LED light to know the working principle of
photodiode

A light-dependent resistor (LDR) is an electronic component that is sensitive to light. It is also


known as a photoresistor. When light falls on its surface, the material conductivity reduces, and the
electrons in the valence band of the device are excited to the conduction band. This makes the
electrons jump from the valence band to the conduction band. The resistance of an LDR changes
with the light intensity that falls upon it. The most common type of LDR has a resistance that falls
with an increase in the light intensity falling upon the device. LDRs are used as light sensors, and
they are often utilized when it is required to detect the presence and absence of light or measure the
light intensity. They have a wide range of applications in industries such as lighting, photography,
and security systems. LDRs are passive components, lacking a P-N junction, and they have a lower
sensitivity than photo diodes and photo transistors.
Applications of LDRs
There are many applications for Light Dependent Resistors. These include:

Lighting switch
The most obvious application for an LDR is to automatically turn on a light at a certain light
level. An example of this could be a street light or a garden light.

Camera shutter control


LDRs can be used to control the shutter speed on a camera. The LDR would be used to
measure the light intensity which then adjusts the camera shutter speed to the appropriate
level.

Dept Of ECE, HKBKCE Pg No: 32 of 41 2022-23

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

Departmental lab -IOT

CHAPTER 5

EXPERIMENTS USING ARDUINO UNO


Our Aim was to learn the basics of embedded systems programming; hence we learnt the essential
programming constructs to the communicate with the electronic devices and its components.
With the knowledge of basics in Arduino programming and familiar with the Arduino UNO board
we have performed the following experiments.
1. Turning On-Off an LED using Arduino
2. Controlling LED using Push Button Switch
3. Measuring Temperature and Humidity
4. Water Sensor
5. Gas Sensor

5.1 Turning On-Off an LED using Arduino:

Fig 5.1: Blinking LED


(image source: [Link]
We used the Arduino IDE and by knowing the basic steps to compile the program and to dump or
upload the program onto the ATMEGA32 Microcontroller in the Arduino UNO board.
Variable declaration, and essence of function calling was understood from this experiment. We used
functions like, void setup( ) and void loop ( ). We declared a global variable to assign a Arduino
pin to the LED. Also we learnt how to instruct the external electronic device like LED to ON or
OFF by using functions like

Dept Of ECE, HKBKCE Pg No: 33 of 41 2022-23

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

Departmental lab -IOT

pinMode(led, OUTPUT) and


digitalWrite(led, HIGH) or digitalWrite(led, LOW)
5.2 Controlling LED using Push Button Switch:
After learning the concept of dumping the program onto the Arduino Uno board we used a PUSH
BUTTON to control the LED on-off. We modified the Blinking LED program by adding a pin
assignment to the Push button switch and connecting the push button to the LED and Arduino UNO
board.

Fig 5.2: LED control using Push button.


(image source: [Link]
Here, we learnt about hoe to receive inputs from the external source and communicate with the
circuit. The receiving function is digitalRead(variableName).
Also serial monitor function was also used to check the correctness of the working using a function
[Link](variableName).
5.3 Measuring Temperature and Humidity:
As proceeding further, we explored the analog signals communication using Arduino. We
performed sensing analog signals for Temperature and Humidity measurement.
Also we learnt on how to include the component library files like DHT11.h in the program.

Fig 5.3: Measuring Temperature and Humidity using Arduino UNO

Dept Of ECE, HKBKCE Pg No: 34 of 41 2022-23

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

Departmental lab -IOT

5.4 Water Sensor:


To know about more sensor devices we performed an experiment on sensing the water droplets and
water level. We used an output device BUZZER to make sound whenever water level exceeds
above the nominal level.

Fig 5.4: Water Sensor Circuit


5.5 Gas Sensor:
To know the significance of the home automation we performed an experiment to sense the hazardous
gas levels using GAS SENSOR MQ2. And we used an output device BUZZER to make sound
whenever Gas leakage is detected above the nominal level.

Fig 5.5: Gas Sensor Circuit

Dept Of ECE, HKBKCE Pg No: 35 of 41 2022-23

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

Departmental lab -IOT

CHAPTER 6
Programs of Mini-Projects using Arduino

6.1 Blinking LED Code using Arduino


This code makes the external LED connected to pin 13
int led = 8; // set the "led" variable as 13

void setup( )
{
pinMode(led, OUTPUT); // designate port 13 as output
}

void loop( )
{
digitalWrite(led, HIGH); // turn the led on
delay(1000); // wait for 1 second

digitalWrite(led, LOW); // turn the led off


delay(1000); // wait for a second
}
6.2 Controlling LED using Push Button Switch:
int switchPin = 12; // switch pin
int ledPin = LED_BUILTIN; // Builtin LED pin
int switchState = LOW; // State of the switch
void setup()
{
[Link](9600); // Start the serial monitor at 9600 baud
pinMode(ledPin, OUTPUT); // Set ledPin as output
pinMode(switchPin, INPUT); // Set the switchPin (12) as input
}

Dept Of ECE, HKBKCE Pg No: 36 of 41 2022-23

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

Departmental lab -IOT

void loop() {
switchState = digitalRead(switchPin); // Read the digital value of the switch (LOW/HIGH)
[Link](switchState); // Print the read value in the serial monitor

if (switchState == HIGH) { // When the button is pressed


digitalWrite(ledPin, HIGH); // Turn the built-in LED on
} else {
digitalWrite(ledPin, LOW); // Turn the built-in LED off
}
}
6.3 Measuring Temperatue and Humidity:
#include<DHT.h>
#define DHTPIN 2
#define DHTTYPE DHT11
DHT Tempy(DHTPIN, DHTTYPE);

void setup() {
// put your setup code here, to run once:
[Link](9600);
[Link]();
}

void loop() {
// put your main code here, to run repeatedly:

int humidity = [Link]();


int temperature = [Link]();

[Link]();
[Link]("Humidity: ");
[Link](humidity);
[Link]("%");

Dept Of ECE, HKBKCE Pg No: 37 of 41 2022-23

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

Departmental lab -IOT

delay(1500);

[Link]("Temperature: ");
[Link](temperature);
[Link]("C");
delay(1500);
}

6.4 Water Sensor:


int water_sensor = A0;
int buzzer = 2;
void setup() {
// put your setup code here, to run once:
[Link](9600);
pinMode(buzzer, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int SensorValue = analogRead(water_sensor);
[Link]("Sensor Value: ");
[Link](SensorValue);
delay(500);
if(SensorValue >= 200)
{
digitalWrite(buzzer, HIGH);
}
else
{
digitalWrite(buzzer, LOW);
}
}

Dept Of ECE, HKBKCE Pg No: 38 of 41 2022-23

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

Departmental lab -IOT

6.5 Gas Sensor:


int gasSensor = A0;
int buzzer = 2;
void setup() {
// put your setup code here, to run once:
pinMode(gasSensor, INPUT);
pinMode(buzzer, OUTPUT);
[Link](9600);
}

void loop() {
// put your main code here, to run repeatedly:
int gasSensorData = analogRead(gasSensor);
[Link](gasSensorData);
delay(500);
if(SensorValue >= 200)
{
digitalWrite(buzzer, HIGH);
}
else
{
digitalWrite(buzzer, LOW);
}
}

SS

Dept Of ECE, HKBKCE Pg No: 39 of 41 2022-23

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

Departmental lab -IOT

CONCLUSION
In conclusion, the exploration and implementation of the Internet of Things (IoT)
using Arduino Uno have opened up a world of endless possibilities and opportunities.
This report delved into the fascinating realm of IoT, showcasing how the integration
of everyday objects with the power of the internet can revolutionize the way we
interact with our surroundings. As we conclude this report, several key takeaways
highlight the significance of this technology and its implications for the future.

Firstly, the Arduino Uno has proven to be an invaluable tool in the development of
IoT projects. Its user-friendly interface and compatibility with various sensors,
actuators, and communication modules have enabled enthusiasts, hobbyists, and
even professionals to embark on innovative ventures. Through practical examples,
we have witnessed how the Arduino Uno acts as the backbone of IoT systems,
facilitating the collection, processing, and transmission of data.

Furthermore, the IoT has transcended mere convenience and has become a catalyst
for efficient resource utilization and smart decision-making. The ability to monitor
and control devices remotely, as demonstrated in the report, is transforming sectors
ranging from agriculture and healthcare to industrial automation and home
management. This has the potential to enhance productivity, optimize resource
allocation, and contribute to sustainable practices on a global scale.

Dept Of ECE, HKBK Pg No: 40 of 41 2022-23

Downloaded by om Raj ([Link]@[Link])


lOMoARcPSD|57908132

Departmental lab -IOT

REFERENCES

[1].[Link]
[2]. [Link]
[3]. [Link]
[4].[Link]
[5]. [Link]
[6].[Link]

Dept Of ECE, HKBK Pg No: 41 of 41 2022-23

Downloaded by om Raj ([Link]@[Link])

You might also like