You are on page 1of 163

Government Polytechnic Mundgod

Dept: computer Science Institute Code:167

Government Polytechnic
Mundagod

DEPARTMENT OF COMPUTER SCIENCE AND ENGG


2021-2022

A Report ON In-plant training


Topic : Python And IOT

Completed at
LCC Group Of Institutions ( ISO 9001-2015)

Duration
20/04/2022 to 01/05/2022

SUBMITTED BY
ASMEEN.S.DODDAMANI

Reg No: 167CS19003


Diploma Final Year

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167

ISO 9001:2015 Certified Institute , Registered By Government Of India & Government Of Karnataka

4TH FLOOR TIMES SQUARE BUILDING OPP ARTS COLLEGE , VIDYANAGAR


HUBLI PH.: 4255747 / lccgroups.com

LCC GROUP OF INSTITUTIONS PROFILE

We have completed 21 years in Northern part of Karnataka with the name of LCC Group Of
Institutions certified under ISO 9001-2015 and recognised by Karnataka State and Central Govt of
India . North Karnataka’s No:1 Educational Institute and we have sprea d our wings in all over
Karnataka. We are a proud bunch of Expert and Experienced Leaders, Administrators, Trainers, Lab
instructors, Marketing Executives and other who continuously work towards the betterment of excellence
of young aspirant students of a wide spread academic array. LCC Group has 29 Branches and 48
Franchises in North Karnataka and the head office is in Hubli. 4 th Floor Times Square Building Opp Arts
College , Vidyanagar Hubli.

Our activities diverge from In House Training, Onsite Training, In-Plant Training, Final Year Projects of
all Streams, Various Computer Courses like C, C++, ANDROID, PYTHON, IoT with Arduino and
Raspberry pi, DJANGO, LARAVAL, PHP, JAVA DEVELOPMENT, WEB DESIGNING, JQUERY,
AZURE, JNODE, CYBER SECURITY,BOOSTRAP, JSCRIPT, WEB DEVELOPMENT, MYSQL,
WORDPRESS, MATLAB, EMBEDED SYSTEMS, C#, MACHINE LEARNING, .NET, ORACLE, MVC,
HARDWARE & NETWORKING, ETHICAL HACKING, REDHAT, LINUX OS, CCNA, MCSE, CLOUD
COMPUTING ,AWS ,Tally, SAP, CAD/CAM/CAE, ANIMATION, GAME DEVELOPMENT ,
INTERIOR DESIGNING, SOFTWARE TESTING, DIPLOMA IN FIRE & SAFETY , DISTANCE
LEARNING and other 43 courses.
Over the years, training alone has not been the activity at our end; quality training has been justified with
quality placement of students. We are proud that many of our students are working in top class MNCs
with good remunerations and a promised career growth.

OUR GOAL :
Completing our commitment to build a “learning society” in which everyone has the opportunity to fulfil
their potential, build a worthwhile career and actively participate in the lives of the community.

Thanks & Regards


POONAM MEHTA HOOLI
Center-Manager-LCC-HUBLI
Contact : 08364255747 / 8951495955

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167

Content

1. Introduction,Features,Advantages,DisAdvantages
2. Variables and Types
3. Basic Operators,TypeCasting,Input Function
4. String Slicing,Built In String Functions
5. Lists,Tuples,Dictionary,Sets,Arrays
6. If Conditions
7. Loops
8. Functions
9. Basic Hardware
10. About Memories
11. Basic IOT
12. Advantages
13. Features

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167

What is Python?

Python is a popular programming language. It was created by Guido van Rossum, and released in
1991.

It is used for:

 web development (server-side),


 software development,
 mathematics,
 system scripting.

What can Python do?

 Python can be used on a server to create web applications.


 Python can be used alongside software to create workflows.
 Python can connect to database systems. It can also read and modify files.
 Python can be used to handle big data and perform complex mathematics.
 Python can be used for rapid prototyping, or for production-ready software development.

Why Python?

 Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc).
 Python has a simple syntax similar to the English language.
 Python has syntax that allows developers to write programs with fewer lines than some
other programming languages.
 Python runs on an interpreter system, meaning that code can be executed as soon as it is
written. This means that prototyping can be very quick.
 Python can be treated in a procedural way, an object-oriented way or a functional way.

Python Features

 Easy to Learn and Use


 Expressive Language
 Interpreted Language
 Cross-platform Language
 Free and Open Source
 Object-Oriented Language
 Extensible
 Large Standard Library
 GUI Programming Support
 Integrated
 Embeddable
 Dynamic Memory Allocation

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167

Variables and Types


Variables are containers for storing data values.
Creating Variables
Python has no command for declaring a variable.
A variable is created the moment you first assign a value to it.
x=5
y=
"John"
print(x)
print(y)
Many Values to Multiple Variables

Python allows you to assign values to multiple variables in one line:

x, y, z = "Orange", "Banana", "Cherry"


print(x)
print(y)
print(z)

Variable Names
A variable can have a short name (like x and y) or a more descriptive name (age, carname,
total_volume). Rules for Python variables:

 A variable name must start with a letter or the underscore character


 A variable name cannot start with a number
 A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
 Variable names are case-sensitive (age, Age and AGE are three different variables)

Example
Legal variable names:

1)myvar = "John"
2)my_var = "John"
3)my_var = "John"
4)myVar = "John"
5)MYVAR =
"John"
6)myvar2 = "John"
Global Variables

Variables that are created outside of a function are known as global variables.
Global variables can be used by everyone, both inside of functions and outside.

x = "Good"
def myfunc():
print("Python is " +
x) myfunc()

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167

Output :
Python is Good

Local Variable

If you create a variable with the same name inside a function, this variable will be local, and can
only be used inside the function. The global variable with the same name will remain as it was,
global and with the original value.

OUT PUT

Python is fantastic
Python is Awesome

Python Data Types


In programming, data type is an important concept.
Variables can store data of different types, and different types can do different things.
Python has the following data types built-in by default, in these categories:

Text Type: str

Numeric Types: int, float, complex

Sequence Types: list, tuple, range

Mapping Type: dict

Set Types: set, frozenset

Boolean Type: bool

Binary Types: bytes, bytearray, memoryview

Example

Print the data type of the variable

x: x = 5
print(type(x));

OUTPUT

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167

Class int

Python Operators
Operators are used to perform operations on variables and
values. print(10 + 5)
Output
15

Python divides the operators in the following groups:

 Arithmetic operators
 Assignment operators
 Comparison operators
 Logical operators
 Identity operators
 Membership operators
 Bitwise operators

Python Arithmetic Operators

Arithmetic operators are used with numeric values to perform common mathematical operations:

Python Assignment Operators

Assignment operators are used to assign values to variables:

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167

Python Comparison Operators


Comparison operators are used to compare two values:

Python Logical Operators

Python Casting
Type casting is a method used to change the variables/ values declared in a certain data type
into a different data type to match the operation required to be performed by the code snippet. In
python, this feature can be accomplished by using constructor functions like int(), string(), float(),
etc

Example
Integer
x = int(1) # x will be 1

Floats:
x = float(1) # x will be 1.0

Strings:
x = str("s1") # x will be 's1'

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167

Python input() Function


Example

Ask for the user's name and print it:

print('Enter your name:')


x = input()
print('Hello, ' + x)

OUTPUT

Enter Your
name Sameer

Hello Sameer.

Python Strings

Strings in python are surrounded by either single quotation marks, or double quotation marks.

'hello' is the same as "hello".

print("Hello")
OR
a=
"Hello"
print(a)

Multiline Strings

You can assign a multiline string to a variable by using three quotes:

Example

You can use three double quotes:

a = """Lorem ipsum dolor sit


amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt
ut labore et dolore magna
aliqua.""" print(a)

OUTPUT
Lorem ipsum dolor sit
amet, consectetur adipiscing
elit,

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167
sed do eiusmod tempor incididunt

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167

ut labore et dolore magna aliqua

Python - Slicing Strings


Slicing
You can return a range of characters by using the slice syntax.
Specify the start index and the end index, separated by a colon, to return a part of the string.

Example
Get the characters from position 2 to position 5 (not included):
b = "Hello, Python!"
print(b[2:5])

OUTPUT
llo

Slice From the Start

By leaving out the start index, the range will start at the first character:

b = "Hello, World!"
Example
print(b[:5])
Get the characters from the start to position 5 (not included):
OUTPUT
Hello
Slice From the Start
By leaving out the start index, the range will start at the first character:
Example
Get the characters from the start to position 5 (not included):
b = "Hello, World!"
print(b[:5])
Slice To the End

By leaving out the end index, the range will go to the end:

b = "Hello, World!"
Example
print(b[2:])
Get the characters from position 2, and all the way to the end:

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167

Python String Methods


Method Description

capitalize() Converts the first character to upper case

casefold() Converts string into lower case

center() Returns a centered string

count() Returns the number of times a specified value occurs


in a string

encode() Returns an encoded version of the string

isdecimal() Returns True if all characters in the string


are decimals

isdigit() Returns True if all characters in the string are digits

isidentifier() Returns True if the string is an identifier

islower() Returns True if all characters in the string are


lower case

isnumeric() Returns True if all characters in the string are numeric

isprintable() Returns True if all characters in the string


are printable

isspace() Returns True if all characters in the string


are whitespaces

istitle() Returns True if the string follows the rules of a title

isupper() Returns True if all characters in the string are upper


case

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167

Python Lists
List

Lists are used to store multiple items in a single variable.

Lists are one of 4 built-in data types in Python used to store collections of data, the other 3
are Tuple, Set, and Dictionary, all with different qualities and usage.

Lists are created using square brackets:

thislist = ["apple", "banana", "cherry"]


Example
print(thislist)
Create Items
Access a List:

List items are indexed and you can access them by referring to the index number:

thislist = ["apple", "banana", "cherry"]


Example
print(thislist[1])
Print the
Range of second
Indexesitem of the list:

You can specify a range of indexes by specifying where to start and where to end the

range. When specifying a range, the return value will be a new list with the specified items.

thislist
Example = ["apple", "banana", "cherry", "orange", "kiwi", "melon", "mango"]
print(thislist[2:5])
Return the third, fourth, and fifth item:
Change Item Value

To change the value of a specific item, refer to the index number:

Example

Change the second item:

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167

thislist = ["apple", "banana", "cherry"]

Append Items
To add an item to the end of the list, use the append() method:

Example
Using the append() method to append an item:

thislist = ["apple", "banana", "cherry"]


thislist.append("orange")
print(thislist)

Insert Items

To insert a list item at a specified index, use the insert() method.


The insert() method inserts an item at the specified index:

Example
Insert an item as the second position:
thislist = ["apple", "banana", "cherry"]
thislist.insert(1, "orange")
print(thislist)

Remove Specified Item

The remove() method removes the specified item.

thislist = ["apple", "banana", "cherry"]


Example
thislist.remove("banana")
Remove "banana":
print(thislist)
Tuple

Tuples are used to store multiple items in a single variable.


A tuple is a collection which is ordered and
unchangeable. Tuples are written with round brackets.

thistuple = ("apple", "banana", "cherry")


Example
print(thistuple)
Create a Tuple:
Ordered

When we say that tuples are ordered, it means that the items have a defined order, and that order

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167

will not change.

Unchangeable

Tuples are unchangeable, meaning that we cannot change, add or remove items after the tuple has
been created.

Allow Duplicates
Since tuples are indexed, they can have items with the same value:
thistuple = ("apple", "banana", "cherry", "apple", "cherry")
Example
print(thistuple)
TuplesTuple
Access allow duplicate
Items values:

You can access tuple items by referring to the index number, inside square brackets:

thistuple = ("apple", "banana", "cherry")


Example
print(thistuple[1])
Print the second item in the tuple:
OUTPUT
Banana
Change Tuple Values

Once a tuple is created, you cannot change its values. Tuples are unchangeable, or immutable as it
also is called.

But there is a workaround. You can convert the tuple into a list, change the list, and convert the list
back into a tuple.

x = ("apple", "banana", "cherry")


Example
y = list(x)
y[1] = the tuple into a list to be able to change it:
Convert
"kiwi" x =
tuple(y)

print(x)

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167

OUTPUT
("apple", "banana", "cherry")

Add Items

Since tuples are immutable, they do not have a build-in append() method, but there are other
ways to add items to a tuple.

1. Convert into a list: Just like the workaround for changing a tuple, you can convert it into a
list, add your item(s), and convert it back into a tuple.

thistuple = ("apple", "banana", "cherry")


Example
y = list(thistuple)
y.append("orange")
Convert the tuple into a list, add "orange", and convert it back into a tuple:
thistuple = tuple(y)
OUTPUT
("apple", "banana", "cherry",'orange')

Add tuple to a tuple.

You are allowed to add tuples to tuples, so if you want to add one item, (or many), create a new
tuple with the item(s), and add it to the existing tuple:

thistuple = ("apple", "banana", "cherry")


Example
y = ("orange",)
thistuple
Create a +=
newy tuple with the value "orange", and add that tuple:
print(thistuple)

OUTPUT
("apple", "banana", "cherry",'orange')

Python Sets
Set
Sets are used to store multiple items in a single variable.
Set is one of 4 built-in data types in Python used to store collections of data,
A set is a collection which is unordered, unchangeable*, and unindexed.
Sets are written with curly brackets.

Example

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167

Create a Set:

thisset = {"apple", "banana", "cherry"}

Set Items

Set items are unordered, unchangeable, and do not allow duplicate values.

Unordered
Unordered means that the items in a set do not have a defined order.
Set items can appear in a different order every time you use them, and cannot be referred to by
index or key.

Unchangeable
Set items are unchangeable, meaning that we cannot change the items after the set has been created.

Access Items

You cannot access items in a set by referring to an index or a key.

But you can loop through the set items using a for loop, or ask if a specified value is present in a set,
by using the in keyword.

Example

Loop through the set, and print the

values: thisset = {"apple", "banana",

"cherry"}

for x in thisset:
print(x)

OUTPUT
apple
banana
cherry
Add Items
Example

Add an item to a set, using the add() method:

thisset = {"apple", "banana", "cherry"}

thisset.add("orange")

print(thisset)

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167

OUTPUT

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167

{"apple", "banana", "cherry","orange"}

Remove Item

To remove an item in a set, use the remove(), or the discard() method.

thisset = {"apple", "banana", "cherry"}


Example
thisset.remove("banana")
Remove "banana" by using the remove() method:
print(thisset)
OUTPUT
{"apple", "cherry"}

Python Dictionaries

Dictionaries are used to store data values in key:value pairs.

A dictionary is a collection which is ordered*, changeable and do not allow duplicates.

Dictionaries are written with curly brackets, and have keys and values:

Example

Create and print a dictionary:


thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
print(thisdict)

Dictionary items are ordered, changeable, and does not allow duplicates.

Dictionary items are presented in key:value pairs, and can be referred to by using the key name

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167

Accessing Items

can access the items of a dictionary by referring to its key name, inside square brackets:

thisdict = {
Example
"brand": "Ford",
"model":
Get "Mustang",
the value of the "model" key:
"year": 1964
}
x = thisdict["model"]

OUTPUT
Mustang

here is also a method called get() that will give you the same result:

x = thisdict.get("model")
Example
OUTPUT
Mustang
Get the value of the "model" key:
Change Values

You can change the value of a specific item by referring to its key name:

thisdict = {
Example
"brand": "Ford",
"model":the
Change "Mustang",
"year" to 2018:
"year": 1964
}
thisdict["year"] = 2018
OUTPUT
"brand": "Ford" ,"model": "Mustang", "year": 2018

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167

Adding Items
Adding an item to the dictionary is done by using a new index key and assigning a value to it:
Example
thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
thisdict["color"] = "red"
print(thisdict)

OUTPUT
("brand": "Ford", "model": "Mustang", "year": 1964,"color":red)

Update Dictionary

The update() method will update the dictionary with the items from a given argument. If the item
does not exist, the item will be added.

The argument must be a dictionary, or an iterable object with key:value pairs.

thisdict.update({"color": "red"})
Removing Items
Example

The pop() method removes the item with the specified key name:

thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
thisdict.pop("model")
print(thisdict)

OUTPUT

{ "brand": "Ford", "year": 1964}

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167

Loop Through a Dictionary

You can loop through a dictionary by using a for loop.

When looping through a dictionary, the return value are the keys of the dictionary, but there are
methods to return the values as well.

Example

Print all key names in the dictionary, one by one:

for x in thisdict:
print(x)
Copy a Dictionary

You cannot copy a dictionary simply by typing dict2 = dict1, because: dict2 will only be
a reference to dict1, and changes made in dict1 will automatically also be made in dict2.

There are ways to make a copy, one way is to use the built-in Dictionary method copy().

Make a copy of a dictionary with the copy() method:

thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
mydict = thisdict.copy()
print(mydict)

OUTPUT

{"brand": "Ford", "model": "Mustang","year": 1964}

Python If ... Else


Python Conditions and If statements

Python supports the usual logical conditions from mathematics:

 Equals: a == b
 Not Equals: a != b
 Less than: a < b
 Less than or equal to: a <= b
 Greater than: a > b
 Greater than or equal to: a >= b

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167

These conditions can be used in several ways, most commonly in "if statements" and loops.

An "if statement" is written by using the if keyword.

Example

If statement:

a = 33
b = 200
if b > a:
print("b is greater than a")

OUTPUT

b is greater than a

Elif

The elif keyword is pythons way of saying "if the previous conditions were not true, then try this
condition".

Example
a = 33
b = 33
if b > a:
print("b is greater than
a") elif a == b:
print("a and b are equal")

OUTPUT

a and b are equal

In this example a is equal to b, so the first condition is not true, but the elif condition is true, so we
print to screen that "a and b are equal".

Else
The else keyword catches anything which isn't caught by the preceding conditions.
Example
a = 200
b = 33
if b > a:
print("b is greater than
a") elif a == b:
print("a and b are
equal") else:

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167

print("a is greater than b")

Short Hand If

If you have only one statement to execute, you can put it on the same line as the if statement.

Example

One line if statement:

if a > b: print("a is greater than b")

OUTPUT

a is greater than b

Short Hand If ...

Else a = 2
b = 330
print("A") if a > b else print("B")

OUTPUT

Python Loops

Python has two primitive loop commands:

 while loops
 for loops

The while Loop

With the while loop we can execute a set of statements as long as a condition is true.

i Example
=1
while i <
6: print(i)
Print
i += 1i as long as i is less than 6:

OUTPUT

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167

12345

The break Statement

With the break statement we can stop the loop even if the while condition is true:

i=1
Example
while i < 6:
print(i)
Exit the loop when i is 3:
if i ==
3:
break
i += 1

OUTPUT

123

The else Statement

With the else statement we can run a block of code once when the condition no longer is true:

i=1
Example
while i < 6:
print(i)
Print a message once the condition is false:
i += 1
else:
print("i is no longer less than

6") OUTPUT

12345

i is no longer less than 6

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167

Python For Loops

A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or
a string).

This is less like the for keyword in other programming languages, and works more like an iterator
method as found in other object-orientated programming languages.

Example

Print each fruit in a fruit list:

fruits = ["apple", "banana",


"cherry"] for x in fruits:
print(x)

OUTPUT

apple

banana

cherry

Nested Loops

A nested loop is a loop inside a loop.

The "inner loop" will be executed one time for each iteration of the "outer loop":

Example

Print each adjective for every fruit:

adj = ["red", "big", "tasty"]


fruits = ["apple", "banana", "cherry"]

for x in adj:
for y in
fruits:
print(x, y)

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167

OUTPUT

red apple

big banana

tasty cherry

big apple

big banana

big cherry

tasty apple

tasty banana

tasty cherry

Python Functions

function is a block of code which only runs when it is

called. You can pass data, known as parameters, into a

function.

A function can return data as a

result. Creating a Function

In Python a function is defined using the def keyword:

Example
def my_function():
print("Hello from a function")
Calling a Function

To call a function, use the function name followed by parenthesis:

Example
def my_function():

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167
print("Hello from a function")

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167

my_function()

OUTPUT

Hello from a function

Arguments

Information can be passed into functions as arguments.

Arguments are specified after the function name, inside the parentheses. You can add as many
arguments as you want, just separate them with a comma.

Example
def my_function(fname):
print(fname + " Refsnes")

my_function("Emil")
my_function("Tobias")
my_function("Linus")

OUTPUT

Emil Refsnes

Tobias Refsnes

Linus Refsnes

Python Exception Handling


Exception Handling

When an error occurs, or exception as we call it, Python will normally stop and generate an error
message.

These exceptions can be handled using the try statement:

Example

The try block will generate an exception, because x is not defined:

try:
print(x)
except:

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167

print("An exception occurred")

OUTPUT
An exception occurred
Since the try block raises an error, the except block will be executed.
Without the try block, the program will crash and raise an error:
Many Exceptions

You can define as many exception blocks as you want, e.g. if you want to execute a special block of
code for a special kind of error:

Example

Print one message if the try block raises a NameError and another for other errors:

try:
print(x)
except NameError:
print("Variable x is not defined")
except:
print("Something else went
wrong") OUTPUT

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167

What is IoT?

The Internet of Things (IoT) is the network of physical objects devices, vehicles,
buildings and other items embedded with electronics, software, sensors, and network connectivity
that enables these objects to collect and exchange data. Kevin Ashton known as the father of IoT.

Where is IoT?

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167

An IoT end point


– Embedded computing and communicationcapabilities
– Open to share messages and data
– Examples – Car, TV, shoes, wearable’s

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167

An IoT end point Architecture

Arduino: prototyping boards


o Arduino is an open-source electronics platform based on easy-to-use hardware and software.
o Arduino boards are based on Microchip’s AVR family microcontrollers.
o Easy to program
o Economical

Arduino Mega Boards

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Arduino Programming Language


o Arduino language is open-source
o Derived from C and Java
o Can be divided in three main parts: structure, values (variables and constants), and functions

Interfacing external LED

Example Programme : BLINKING LED

2 21-2022 Government Polytechnic


Government Polytechnic
Dept: computer Institute

MODULAR IoT FRAMEWORK Complete Development Solution for Secure Internet


of Things Systems

"The IoT demands an extensive range of new technologies and skills that many organizations have yet to
master… A recurring theme in the IoT space is the immaturity of technologies and services and of the
vendors providing them. Architecting for this immaturity and managing the risk it creates will be a key
challenge for organizations exploiting the IoT. In many technology areas, lack of skills will also pose
significant challenges."

Introducing the NXP Modular IoT Framework

• A forward looking architecture to create any specific IoT use case.


• Enabling secure mix and match of diverse technologies/systems.
• Ensuring compatibility and interoperability, reducing risk, skill gaps and time to market

The Many Functional Dimensions of IoT Systems

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

NXP Modular IoT Framework Integrated Development Experience (IDEx)

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Framework Architecture Enables Fast & Easy Creation of any IoT System

Starter IDEx Shipping Today

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

o Modular edge node platform with Thread and ZigBee support


o Modular gateway with support for Thread and ZigBee, Wi-Fi and Ethernet, and secure element
o NFC based device commissioning
o Smart phone app reference design for device control via cloud
o Cloud service reference design on Amazon Web Services, and cloud connectivity reference design
using MQTT and CoAP

Oil Field Equipment & Building Monitoring System

NXP’s Modular IoT Framework Solution Summary

o BUILT-IN SECURITY AND INTEROPERABILITY


Secure connections from the end-node to the cloud

o FRAMEWORK ENABLES MIX & MATCH FLEXIBILITY


Delivering robust building blocks – tested & verified to work together

o SPEEDING IoT SYSTEM DEVELOPMENT

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute
Framework architecture for any specific IoT use case

o INTEGRATED DEVELOPMENT EXPERIENCE


Customers can leverage targeted use cases out of the box

The Microsoft Architecture for the Internet of Things (IoT)


IoT solutions until now
o Most of the early successful IoT deployments were either.
o For very complex and expensive devices, where the cost of a custom hardware/software solution
is acceptable compared to the cost of the device .
o For high-volume, homogeneous devices, where the software needs are relatively simple.

Emerging Challenges for IT

o Scale
# devices >> # users, and growing fast Volume of data (and network traffic)
o Pace
Innovation pressure: analysis, command and control, cost Skill pressure: data science, new platforms
o Environment
IT/OT collaboration Security and privacy threats Emerging standards New competitors.

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

IoT Device & Cloud Patterns

Microsoft Azure IoT services

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

IoT architecture requirements


o Handle extreme hardware and software heterogeneity.
o Build for hyper-scale and enable low data latency.
o Be secure by design; support defense in depth.
o Lower barriers to entry: evaluate -> prototype -> deploy.
o Deliver telemetry and notifications that are meaningful even at extreme scale.
o Provide hot-path and cold-path analysis and action/response.

Pattern: Telemetry First

o Start with telemetry.


It is very hard to predict in advance what data will be useful.

o The important data may not be what you expected.


It is tempting, but likely inefficient to try for business transformation in the first step.
Think about not only device telemetry but also diagnostic telemetry.

o Address privacy, management and security before command & control


Privacy and security implications of telemetry are generally lesser than for command and control.
Telemetry today

o High scale data ingestion via Event Hub.


o High scale stream processing via Stream Analytics (or HDInsight /Storm)
o Storage for cold-path analytics
o Processing for hot-path analytics

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Event Hubs

o Cloud-scale telemetry ingestion from websites, apps, and devices


o Compatible with more than a million publishers supporting HTTP, AMQP and MQTT
o Ingress millions of events per second
o SAS based security, with unique token per publisher
o Configurable data retention (1-30 days)
o Low latency (<10 ms for volatile data)
o Pluggable with other cloud services like Stream Analytics
Stream Analytics
o Real-time analytics for Internet of Things solutions
o Stream millions of events per second
o Mission critical reliability, performance and predictable results
o Rapid development with familiar SQL-based language

IoT Telemetry with Event Hubs and Stream Analytics Demo

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

JavaScript (to Event Hub)

var eventBody = { "reading": x, "device_id": id };


ehClient = new EventHubClient({
'name': "kevinmil-demo", 'namespace': "kevinmil-demo-ns",
'sasKey': <snipped>, 'sasKeyName': "sendTelemetry",
'timeOut': 10,
});

var msg = new EventData(eventBody);

ehClient.sendMessage(msg, function (messagingResult) {


// <body snipped>
});

Stream Analytics (to blob)

SELECT
device_id as
Device_Id, reading as
Reading,
EventProcessedUtcTime as
UTCDateTime FROM [eventhub]
INTO [out2blob]

Stream Analytics (to SQL)

SELECT
System.TimeStamp as UTCDateTime, device_id as Device_Id,
COUNT (*) as Count
FROM [iotdemoeventhub] TIMESTAMP BY EventProcessedUtcTime
INTO [alertCounts]
WHERE ( CAST(reading AS float) > 115.0 )
GROUP BY device_id, SlidingWindow(second,
15) HAVING COUNT(*) > 1
SELECT
device_id as Device_Id, reading as Reading,
EventProcessedUtcTime as UTCDateTime
FROM [iotdemoeventhub] TIMESTAMP BY EventProcessedUtcTime
INTO [stream2sql]

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Demo
o Think about a scalable architecture, but start small, and start with telemetry.
o It is straight forward to get a telemetry example running with very limited coding.

Pattern: Don’t interrupt the fast path

o In the telemetry example, Event Hub data flows directly into Stream Analytics.
o Both components are designed for high scale.
o Don’t process between high-scale components unless you can handle that scale.

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Pattern: Defence in depth

The entire organization needs to be focused on security, and that focus must inform the entire product lifecycle.

Think about security on the device, at the field gateway (if one exists) and in the cloud.

Azure IoT Suite

o Accelerate time-to-value by easily deploying IoT applications for the most common use cases, such
as remote monitoring, asset management, and predictive maintenance.

o Plan and budget appropriately through a simple, predictable business model.


o Grow and extend solutions to support millions of assets

Pattern: Build to the reference architecture

o The forthcoming IoT Suite will ease the design and deployment of IoT applications for the most
common use cases.
o Highly portable client libraries support easy cloud connection for devices and gateways.
o IoT Hub will extend Event Hubs to include device provisioning, identity, command & control,
and management.
o Building to the reference architecture will simplify conversion to the IoT Suite.

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Azure IoT Reference Architecture

Demo 2

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Basic Electronics I
1. Electrons: The smallest amount of electrical charge having the quality called negative polarity.
2. Conductors: Materials in which electrons can move freely from atom to atom with the application
of voltage are called conductors.
3. Insulators: Materials in which electrons tend to stay put and do not flow easily from atom to atom
are termed insulators. Insulators are used to prevent the flow of electricity.
4. Semi-Conductors: Materials which are neither conductors nor insulators Common semi
conductor materials are carbon, germanium and silicone.
5. The Symbol for Charge: The symbol for charge is Q which stands for quantity.The practical unit of
charge is called the coulomb (C).
6. Voltage: Any charge has the potential to do the work of attracting a similar charge or repulsing
an opposite charge.
7. Current: When a charge is forced to move because of a potential difference (voltage) current is produced.
8. Amperes: Current indicates the intensity of the electricity in motion. The symbol for current is I (for
intensity) and is measured in amperes.
9. Resistance: Opposition to the flow of current is termed resistance.
10. Ohms: The practical unit of resistance is the ohm designated by the Greek letter omega: Ω
11. Closed Circuits: In applications requiring the use of current, electrical components are arranged in the
form of a circuit.
Common Electronic Component Symbols

12. DC: Circuits that are powered by battery sources are termed direct current circuits.
13. AC: An alternating voltage source periodically alternates or reverses in polarity.
14. Impedance: Impedance is resistance to current flow in AC circuits and its symbol is .
15. Grounding: For electronic equipment, the ground just indicates a metal chassis, which is used as
a common return for connections to the source.
16. Power: The unit of electrical power is the watt. Power is how much work is done over time.

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Microcontroller
What is a Microcontroller? :
A Microcontroller is a VLSI (Very Large Scale Integration) Integrated Circuit (IC) that contains electronic
computing unit and logic unit (combinedly known as CPU), Memory (Program Memory and Data
Memory), I/O Ports (Input / Output Ports) and few other components integrated on a single chip.

Microcontroller is also called as a Computer-on-a-Chip or a Single-Chip-Computer. Since the Microcontroller


and its supporting circuitry are often embedded in the device it controls, a Microcontroller is also called as an
Embedded Controller.
Microcontrollers are omnipresent. If a device or an application involves measuring, storing, calculating,
controlling or displaying information, then device contains a Microcontroller in it. Let us see some of the
areas where microcontrollers are used.
The biggest user of Microcontrollers is probably the Automobiles Industry. Almost every car that comes
out of the assembly factory contains at least one Microcontroller for the purpose of engine control. You can
find many more Microcontrollers for controlling additional systems.
Consumer Electronics is another area which is loaded with Microcontrollers. Microcontrollers are a part of
Digital Cameras, Video Camcorders, CD and DVD Players, Washing Machines, Ovens, etc.
Microcontrollers are also used in test and measurement equipment like Multimeters, Oscilloscopes, Function
Generators, etc. You can also find microcontrollers near your desktop computer like Printers, Routers,
Modems, Keyboards, etc.
Basics of Microcontrollers
Basically, a Microcontroller consists of the following components.

 Central Processing Unit (CPU)


 Program Memory (ROM – Read Only Memory)
 Data Memory (RAM – Random Access Memory)
 Timers and Counters
 I/O Ports (I/O – Input /Output)
 Serial Communication Interface
 Clock Circuit (Oscillator Circuit)
 Interrupt Mechanism

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Basic Structure of a Microcontroller

Advantages of Microcontrollers
 A Microcontroller is a true device that fits the computer-on-a-chip idea.
 No need for any external interfacing of basic components like Memory, I/O Ports, etc.
 Microcontrollers doesn’t require complex operating systems as all the instructions must be written and
stored in the memory. (RTOS is an exception).
 All the Input/Output Ports are programmable.
 Integration of all the essential components reduces the cost, design time and area of the product
(or application).
Disadvantages of Microcontrollers
 Microcontrollers are not known for their computation power.
 The amount of memory limits the instructions that a microcontroller can execute.
 No Operating System and hence, all the instruction must be written.
 Applications of Microcontrollers
 There are huge number of applications of Microcontrollers. In fact, the entire embedded
systems industry is dependent on Microcontrollers.

Applications of Microcontrollers.

 Front Panel Controls in devices like Oven, washing Machine etc.


 Function Generators
 Smoke and Fire Alarms
 Home Automation Systems
 Automatic Headlamp ON in Cars
 Speed Sensed Door Locking System

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Microprocessor
A Microprocessor, popularly known as “computer on a chip” in its early days, is a general purpose central
processing unit (CPU) fabricated on a single integrated circuit (IC) and is a complete digital computer (later
microcontroller is considered to be more accurate form of complete computer). It is a small but very powerful
electronic brain that operates at a blistering speed and is often used to carry out instructions of a computer
program in order to perform arithmetic and logical operations, storing the data, system control, input / output
operations etc. as per the instructions. The key term in the definition of a microprocessor is “general purpose”.

It means that, with the help of a microprocessor, one can build a simple system or a large and complex
machine around it with a few extra components as per the application. The main task of a microprocessor is
to accept data as input from input devices then process this data according to the instructions and provide the
result of these instructions as output through output devices. Microprocessor is an example of sequential logic
device as it has memory internally and uses it to store instructions.

The block diagram of a microprocessor

The internal structure of a microprocessor is shown below.

2021- Government Polytechnic


Government Polytechnic Mundgod
Dept: computer Science Institute Code:167

Main Difference between AVR, ARM, 8051 and PIC Microcontrollers

8051 PIC AVR ARM

8-bit for standard 32-bit mostly also


Bus width core 8/16/32-bit 8/32-bit available in 64-bit
UART, USART, LIN,
I2C, SPI, CAN, USB,

UART, USART, SPI, Ethernet, I2S, DSP,


Communication PIC, UART, USART, I2C, (special purpose SAI (serial audio
UART, LIN, CAN, Ethernet, AVR support CAN,
Protocols USART,SPI,I2C SPI, I2S USB, Ethernet) interface), IrDA
12 Clock/instruction 4 Clock/instruction 1 clock/ instruction 1 clock/ instruction
Speed cycle cycle cycle cycle
Flash, SRAM, Flash, SDRAM,
Memory ROM, SRAM, FLASH SRAM, FLASH EEPROM EEPROM

Some feature of RISC


ISA CLSC RISC RISC
Von Neumann Modified Harvard
Memory Architecture architecture Harvard architecture Modified architecture

Power
Consumption Average Low Low Low

PIC16,PIC17, PIC18, Tiny, Atmega, Xmega, ARMv4,5,6,7 and


Families 8051 variants PIC24, PIC32 special purpose AVR series

Community Vast Very Good Very Good Vast

NXP, Atmel, Silicon Apple, Nvidia,


Labs, Dallas, Cyprus, Qualcomm, Samsung
Manufacturer Infineon, etc. Microchip Average Atmel Electronics, and TI etc.
Cost (as
compared to
features provide) Very Low Average Average Low

High speed operation

Vast

Other Feature Known for its Standard Cheap Cheap, effective

Popular LPC2148, ARM Cortex-


PIC18fXX8, PIC16f88X, Atmega8, 16, 32, Arduino M0 to ARM Cortex-M7,
Microcontrollers AT89C51, P89v51, etc. PIC32MXX Community etc.

2021-2022 Government Polytechnic Mundagod


Government Polytechnic
Dept: computer Institute

ARM Processor

An ARM processor is any of several 32-bit RISC ( reduced instruction set computer) microprocessors
developed by advanced RISC machines , Ltd .

ARM processors are extensively used in consumer electronic devices such as smart phones, tablets ,
multimedia players and other mobile devices .

The ARM processors smaller size , reduced complexity and lower power consumption makes them suitable
for increasingly miniaturized devices.

ARM Processor Feature


 Load/store Architecture.
 An Orthogonal instruction set.
 Mostly single cycle execution.
 Enhanced power saving design.
 64 and 32-bit execution state for scalable high performance.
 Hardware virtualization support.

ARM Cortex Processor (v7)


 ARM Cortex-A family (v7-A):
 Applications
processors for full OS x1-4
and 3rd party Cortex-A15
applications x1-4
Cortex-A9
 ARM Cortex-R family (v7-R): Cortex-A8
 Embedded processors for real- x1-4
time signal processing, control Cortex-A5
applications 1-2
R Heron
 ARM Cortex-M family (v7-M):
Cortex-R4
 Microcontroller-oriented
processors for MCU and Cortex-M4
SoC applications SC300™
Cortex™-M3

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

ARM Architecture

PRINTED CIRCUIT BOARD


A printed circuit board (PCB) mechanically supports and electrically connects electronic
components or electrical components using conductive tracks, pads and other features etched from one or
more sheet layers of copper laminated onto and/or between sheet layers of a non-conductive substrate.
Components are generally soldered onto the PCB to both electrically connect and mechanically fasten
them to it.
Printed circuit boards are used in all but the simplest electronic products. They are also used in some
electrical products, such as passive switch boxes.

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Hardware Parts
MOTHER BOARD

List of ports and connectors

 Mouse & Keyboard


 USB
 Parallel port
 CPU Chip
 RAM slots
 Floppy controller
 IDE controller
 PCI slot
 ISA slot
 CMOS Battery
 AGP slot
 CPU slot
 Power supply plug in

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Add on Cards

 Video cards
 Sound cards
 Network cards
 TV tuner cards
 POST cards
 Compatibility card

The chipset

 It handles the data transfer between devices connected to motherboard.


 It consists of two integrated circuits (IC) known as Northbridge and Southbridge.

BIOS

Acronym of BIOS is Basic Input Output System. It is a program (set of instructions) written in machine
level language. This program is stored in permanent semiconductor memory called Flash ROM located on
the motherboard.

Identifying IDE Data Bus

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Identifying SATA Hard Disk Drive Data Bus

Identifying Floppy Disk Drive Data Bus

Identifying Parallel Printer Cable Connector

Identifying VGA Monitor Connectors

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Identifying LCD Monitor Connectors

Identifying External Audio Cable Connector

LED

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Troubleshooting
If you've tried the basic troubleshooting steps and your LCD still doesn't work properly, you may have one or
more of the following problems:

No image

If your LCD displays no image at all and you are certain that it is receiving power and video signal, first
adjust the brightness and contrast settings to higher values. If that doesn't work, turn off the system and LCD,
disconnect the LCD signal cable from the computer, and turn on the LCD by itself. It should display some
sort of initialization screen, if only perhaps a "No video signal" message. If nothing lights up and no message
is displayed, contact technical support for your LCD manufacturer. If your LCD supports multiple inputs, you
may need to press a button to cycle through the inputs and set it to the correct one.

Screen flickers

Unlike CRTs, where increasing the refresh rate always reduces flicker, LCDs have an optimal refresh rate
that may be lower than the highest refresh rate supported. For example, a 17" LCD operating in analog mode
may support 60 Hz and 75 Hz refresh. Although it sounds counterintuitive to anyone whose experience has
been with CRTs, reducing the refresh rate from 75 Hz to 60 Hz may improve image stability. Check the
manual to determine the optimum refresh rate for your LCD, and set your video adapter to use that rate.

The screen is very unstable

First, try setting the optimal refresh rate as described above. If that doesn't solve the problem and you are
using an analog interface, there are several possible causes, most of which are due to poor synchronization
between the video adapter clock and the display clock, or to phase problems. If your LCD has an auto-adjust,
auto-setup, or auto-synchronize option, try using that first. If not, try adjusting the phase and/or clock
settings manually until you have a usable image.

"Signal out of range" message


Your video card is supplying a video signal at a bandwidth that is above or below the ability of your LCD to
display. Reset your video parameters to be within the range supported by the LCD. If necessary, temporarily
connect a different display or start Windows in Safe Mode and choose standard VGA in order to change video
settings.

Text or lines are shadowed, jaggy, or blocky

This occurs when you run an LCD at other than its native resolution. For example, if you have a 19" LCD
with native 1280x1024 resolutions but have your display adapter set to 1024x768, your LCD attempts to
display those 1024x768 pixels at full screen size, which physically corresponds to 1280x1024 pixels.

Floppy disk drive (FDD).

Basically, a floppy disk drive reads and writes data to a small, circular piece of metal-coated plastic
similar to audio cassette tape. Floppy disk, like a cassette tape, is made from a thin piece of plastic coated
with a magnetic material on both sides. However, it is shaped like a disk rather than a long thin ribbon.
The

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

tracks are arranged in concentric rings so that the software can jump from "file 1" to "file 19" without
having to fast forward through files 2-18. The diskette spins like a record and the heads move to the
correct track, providing what is known as direct access storage.

Basic floppy disk drive troubleshooting

 Bad floppy diskette


 Verify that the floppy diskette that you are attempting to read from is not write protected or bad.
Verify that the diskette is not write protected by sliding the tab into the position not allowing
light to shine through it. If you do not have a tab place tape over this hole.
 Because of the technology of floppy diskette drives, it is likely for a floppy diskettes to
become bad. Verify that other floppy diskettes are not exhibiting the same issue.
 If other floppies work it is likely that you may have a bad floppy diskette.
 Not setup in CMOS
 Verify that the floppy drive is properly setup in CMOS Setup. If the floppy drive is not setup
properly you may experience read/write errors or the floppy may not work at all. Most
computers need to have the floppy setup as a 3.5, 1.44MB.
 Confliction with other hardware
 Not connected properly

HARD DISK DRIVE

A hard disk drive (HDD) is a data storage device used for storing and retrieving DATA.
Data is read in a random-access manner, meaning individual blocks of data can be stored or retrieved
in any order rather than sequentially.
An HDD consists of one or more rigid ("hard") rapidly rotating disks (platters) with magnetic heads
arranged on a moving actuator arm to read and write data to the surfaces.

Troubleshoot hard drive

The system does not recognize the drive.


Check Physical connectivity:

1. Is the drive receiving power?


2. Is it correctly connected with cable
3. its jumpers set correctly?
2. BIOS setup: Does the BIOS see the drive?
3. Viruses—Does the drive contain any boot sector viruses?
4. Partitioning—Does FDISK find a valid partition on the drive? Is it active?
5. Formatting—Is the drive formatted using a file system that the OS can recognize?
6. Drive errors—Is a physical or logical drive error causing read/write problems on the drive?
7.Operating system—Does your OS have a feature that checks the status of each drive on your system? If
so, what is that status?
8. Disk Management: most important thing to check is the status of each drive. For example, If there
are two hard disks: one FAT32 and one NTFS. Both are reported to be Healthy. If a drive reports that it
is offline or a status other than Healthy, right-click it and choose Reactivate Disk.
9. The system error message, "HDD controller failure" appears. Confirm the jumper settings on
the drive.

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

10. "Disk Boot Failure," "Non-System Disk" or "No ROM Basic - SYSTEM HALTED" appears.:
same as physical connectivity
11. The system error message, "Drive not Ready," appears.: Check all cable connection, Make sure
the power supply is adequate for system needs, Reboot the computer and make sure the drive spins up

Operating System
It is very difficult to distinguish between Application S/W we buy and Application S/W came up with
O.s. For example Internet Explorer(Browser),Outlook Express (E-mail client),Media Player
People use O.S for diff purposes i.e. Ordinary people use to run applications, Admin’s use to
maintain System & Programmers use to develop new programme's.
Normal user whatever seeing is nothing but GUI or CLI, for normal users O.S provides an interface to run
their favorite Applications.

Services provided by KERNEL

 File services: Opening closing saving deleting of files.


 I/O services: Opening I/O device, Closing, reading, modifying
 Memory Allocation: Dynamic memory allocation, memory freeing, Mapping a file or device
into memory space
 Network communication services: Creating a n/w communication object such as Socket,
Sending data to remote socket, reading data of remote socket, Modifying and Closing the socket

Identifying Functionalities of Operating System

 User interface
 File management
 Device management
 Memory management
 Process management
 Networking
 Security

Samples of Operating Systems


Single Task Application: DOS is the simplest O.S. It does not support multi tasking. So only one
application can be ran on DOS. It can’t use physical memory present on the board
Embedded or Real time O.S: Compared to DOS these O.S are designed for 32 Bit processing and They
can use physical memory present on the board. And these will support multi tasking. They will use
priority based schedule.
Multi Processing O.S: Unix, Linux, and Windows support multiple processes by providing virtual
memory for each processes. Each process is isolated from other processes, so one process cannot access
the memory of other process.

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

What is DOS?
DOS (from Disk Operating System) commonly refers to the family of closely related operating systems
which dominated the IBM PC compatible market between 1981 and 1995. It is a single user, single
tasking, and text-based operating system. DOS is designed to run on IBM PC compatible type hardware
using the Intel x86 or compatible CPU. Some common examples of DOS are: PC-DOS, MS-DOS, etc.
Initially MS-DOS was available as a standalone product and MS-DOS 7.0 was the last version available
as a standalone product. Starting with Windows 95 and later Windows versions, DOS was integrated into
the Windows environment itself as the Command Prompt.

TROUBLE SHOOTING

Problem: Power button will not start computer

Solution 1: If your computer does not start, begin by checking the power cord to confirm that it is
plugged securely into the back of the computer case and the power outlet.
Solution 2: If it is plugged into an outlet, make sure it is a working outlet. To check your outlet, you can
plug in another electrical device, such as a lamp.
Solution 3: If the computer is plugged in to a surge protector, verify that it is turned on. You may have
to reset the surge protector by turning it off and then back on. You can also plug a lamp or other device
into the surge protector to verify that it's working correctly.
Solution 4: If you are using a laptop, the battery may not be charged. Plug the AC adapter into the wall,
then try to turn on the laptop. If it still doesn't start up, you may need to wait a few minutes and try again.

Problem: An application is running slowly

Solution 1: Close and reopen the application.


Solution 2: Update the application. To do this, click the Help menu and look for an option to check
for Updates. If you don't find this option, another idea is to run an online search for application updates.

Problem: An application is frozen

Sometimes an application may become stuck, or frozen. When this happens, you won't be able to close the
window or click any buttons within the application.
Solution 1: Force quit the application. On a PC, you can press (and hold) Ctrl+Alt+Delete (the Control,
Alt, and Delete keys) on your keyboard to open the Task Manager. On a Mac, press and
hold Command+Option+Esc. You can then select the unresponsive application and click End
task (or Force Quit on a Mac) to close it.
Solution 2: Restart the computer. If you are unable to force quit an application, restarting your computer
will close all open apps.

Problem: All programs on the computer run slowly

Solution 1: Run a virus scanner. You may have malware running in the background that is slowing
things down.

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Solution 2: Your computer may be running out of hard drive space. Try deleting any files or programs you
don't need.
Solution 3: If you're using a PC, you can run Disk Defragmenter. To learn more about Disk
Defragmenter, check out our lesson on Protecting Your Computer.

Background Programs

 One of the most common reasons for a slow computer are programs running in the background.
Remove or disable any TSRs and startup programs that automatically start each time the
computer boots.
 Delete temp files
 As a computer runs programs, temporary files are stored on the hard drive. Deleting these temp
files can help improve computer performance.
 First, we suggest using the Windows Disk Cleanup utility to delete temporary files and other files
no longer needed on the computer.
 Free hard drive space
 Verify that there is at least 200-500MB of free hard drive space. This available space allows
the computer to have room for the swap file to increase in size, as well as room for temporary
files.
 Bad, corrupted or fragmented hard drive
 Run ScanDisk, chkdsk, or something equivalent to verify there is nothing physically wrong with
the computer's hard drive.
 Run Defrag to help ensure that data is arranged in the best possible order.
 Use other software tools to test the hard drive for any errors by looking at the SMART of the drive.
 Scan for malware and viruses
 Hardware conflicts
 Verify that the Device Manager has no conflicts. If any exist, resolve these issues as they could be
the cause of your problem.
 Update Windows
 Make sure you have all the latest Windows updates installed on the computer.
 If you are on the Internet when your computer is slow, make sure all browser plugins are up-to-
date. You can also try disabling browser plug-ins to see if one of them is causing the slowness.
 Memory upgrade
 If you have had your computer for more than two years, you may need more memory.
 Run Registry cleaner
 We normally do not recommend Registry cleaners. However, if you have followed all of the
above steps and your computer is still slow, try running a Registry cleaner on the computer.
 Computer or processor is overheating
 Make sure your computer and processor is not overheating. Excessive heat can cause a
significant decrease in computer performance because most processors automatically reduce the
speed of the processor to help compensate for heat-related issues

Problem: The computer is frozen

Sometimes your computer may become completely unresponsive, or frozen. When this happens, you
won't be able to click anywhere on the screen, open or close applications, or access shut-down options.
Solution 1 (Windows only): Restart Windows Explorer. To do this, press and hold Ctrl+Alt+Delete on
2021- Government Polytechnic
Government Polytechnic
Dept: computer Institute

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

your keyboard to open the Task Manager. Next, locate and select Windows Explorer from
the Processes tab and click Restart. You may need to click More Details at the bottom of the window to
see the Processes tab.
Solution 3: Press and hold the Power button. The Power button is usually located on the front or side of
the computer, typically indicated by the power symbol. Press and hold the Power button for 5 to 10
seconds to force the computer to shut down.
Solution 4: If the computer still won't shut down, you can unplug the power cable from the
electrical outlet. If you're using a laptop, you may be able to remove the battery to force the computer
to turn off. Note: This solution should be your last resort after trying the other suggestions above.

Problem: The mouse or keyboard has stopped working

Solution 1: If you're using a wired mouse or keyboard, make sure it's correctly plugged into the
computer. Solution 2: If you're using a wireless mouse or keyboard, make sure it's turned on and that its
batteries are charged

Problem: The sound isn't working

Solution 1: Check the volume level. Click the audio button in the top-right or bottom-right corner of the
screen to make sure the sound is turned on and that the volume is up.
Solution 2: Check the audio player controls. Many audio and video players will have their own separate
audio controls. Make sure the sound is turned on and that the volume is turned up in the player.
Solution 3: Check the cables. Make sure external speakers are plugged in, turned on, and connected to the
correct audio port or a USB port. If your computer has color-coded ports, the audio output port will
usually be green.
Solution 4: Connect headphones to the computer to find out if you can hear sound through the
headphones.

Problem: The screen is blank

Solution 1: The computer may be in Sleep mode. Click the mouse or press any key on the keyboard to
wake it.
Solution 2: Make sure the monitor is plugged in and turned on.
Solution 3: Make sure the computer is plugged in and turned on.
Solution 4: If you're using a desktop, make sure the monitor cable is properly connected to the computer
tower and the monitor.

I have problems in Windows after installing new software


i) Reinstall or uninstall the program
ii) If you are encountering problems with your computer or other programs after installing
new software on your computer, uninstall the program and see if the issues persist.
iii) Note: If, after installing a program, you're unable to boot into Windows, try booting into Safe
Mode.
iv) After the program has been uninstalled, try installing the program again.
v) Check for software program updates or new versions
vi) If you continue to experience issues, check the software manufacturer' website for any updates to

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

the program, game, or utility you are installing.

If you're installing a software program or drivers for a hardware device, such as a printer, get the latest
software and drivers from the manufacturer instead of using the included software. See our drivers
page for links to different types of hardware drivers.

Networking

Network

A group of interconnected computers and other devices sharing resources that are connected by some
type of transmission media.

Minimum requirements

 Data to share
 A physical pathway (Transmission Medium)
 Protocols (Rules of communication)

Advantages

⚫ Sharing files & resources

⚫ Enhancing & Improved communications.

⚫ Increasing storage capacity

⚫ Reduce costs.

Disadvantages

⚫ Lack of data security and privacy

⚫ Costly and complex wiring

⚫ Complicated & expensive network software

⚫ Server crashing

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Basic Components of Networks

Network Examples
components

Media Co-Axial, TPC, FOC, microwave etc

Processors Repeaters. modem, hub, switch etc

Software Communication S/W, Networking Ope.System, P to P, POP, SMTP


etc

Channels Analog / Digital, switched/non-switched ckt, simplex/duplex

Topology Bus ,Star , Ring, mesh, Ethernet

Architecture OSI ,IEEE ,ISO , EIA/TIA etc.

Network Topology
The Topology defines the way to arrange computers in network. Bus Topology, Ring Topology, Star
Topology, Mesh Topology And Tree Topologies are some types of topologies.

Types of Computer Network

 LAN - Local Area Network

 MAN- Metropolitan Area Network

 WAN - Wide Area Network

Local Area Network

⚫ A local area network (LAN) is a computer network that interconnects computers within a
limited area such as a residence, school, laboratory, university campus or office building.

⚫ Ethernet and Wi-Fi are the two most common technologies in use for local area networks.

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Metropolitan area network (MAN)

⚫ A metropolitan area network (MAN) is a network that interconnects users with computer resources in a
geographic area or region larger than that covered by even a large local area network (LAN) but smaller
than the area covered by a wide area network (WAN). The term is applied to the interconnection of
networks in a city into a single larger network (which may then also offer efficient connection to a wide
area network). It is also used to mean the interconnection of several local area networks by bridging
them with backbone lines. The latter usage is also sometimes referred to as a campus network.

⚫ Examples of metropolitan area networks of various sizes can be found in the metropolitan areas of
London, England; Lodz, Poland; and Geneva, Switzerland. Large universities also sometimes use the
term to describe their networks. A recent trend is the installation of wireless MANs.

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Wide Area Network


⚫ A wide area network (WAN) is a telecommunications network or computer network that extends
over a large geographical distance. Wide area networks are often established with leased
telecommunication circuits.

⚫ Business, education and government entities use wide area networks to relay data among staff,
students, clients, buyers, and suppliers from various geographical locations. In essence, this mode of
telecommunication allows a business to effectively carry out its daily function regardless of
location. The Internet may be considered a WAN

Protocol
⚫ In information technology, a protocol is the special set of rules that end points in a
telecommunication connection use when they communicate. Protocols specify interactions between
the communicating entities

Ex: IP, TCP, UDP, POP,SMTP,HTTP.

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

HTTP (Hyper Text Transfer Protocol):


⚫ This is the most widely used protocol on the web. In order to fetch a web page for you, your web
browser must "talk" to a web server on the Internet. When web browsers talk to web servers, they
use HTTP protocol (HyperText Transfer Protocol).

⚫ All browsers use this protocol whether they are Windows based or Linux based

FTP (File Transfer Protocol):

⚫ File Transfer Program is used to transfer files from one computer to another. FTP is

⚫ the most widely used protocol by network administrators for:

⚫ i. Taking backups

⚫ ii. Uploading or downloading files to/from the server machine

⚫ iii.Providing a platform for file storage among many different hosts (such as workstations,
routers, servers, etc.)

Email Protocols (SMTP, POP, and IMAP):

After HTTP, arguably, the most widely used web resource is email.network administrator configures an
email client on host computers quite often, and therefore need to know the functioning and configuration of
email client software. The protocols that are commonly used when accessing email over the Internet or
intranet are given below:
• SMTP,
• POP3, and IMAP

⚫ SMTP is the protocol used for accessing the Email Server for sending email messages from client
computer to the Server, whereas POP and IMAP are used for receiving email messages from the
Email Server to the client computer. Note that an Email Server may be a Web Server doing the
additional duty of Email Server.

⚫ i. SMTP: SMTP stands for Simple Mail Transfer Protocol. It is an "outgoing mail" server that is used
for sending email messages from the client computer to the remote mail server. You need to
configure your email client with proper SMTP server information for sending messages. SMTP uses
port 25.

⚫ ii. POP3 and IMAP: POP and IMAP are protocols that are used for fetching email from an Email
Server. The main difference between POP and IMAP are that the former does not keep a copy of
email messages on the server, whereas IMAP can synchronize with the email folders on the server and
maintain a copy of the same locally. The advantage of using IMAP is the ability to roan. You can
access the the email server from home as well as office and keep your INBOX, OUTBOX and other
folders synchronized using IMAP. POP3 uses port number 110 where as IMAP uses port number 143.

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Basic hardware requirements to form a network are –

⚫ Network Interface Card (NIC) or LAN Card

⚫ Media - Wired or Wireless

⚫ Networking devices - Hubs, Switches, Routers etc.

⚫ Cable Connectors

Entities of Computer Network

 Service Provider (SERVER)


 Service Requester(CLIENT)
 Peers (BOTH)

The Client Server Architecture


⚫ In a Client Server architecture the communication takes place between Server and Client.

Types of Architecture are

 The Two Tier Architecture: In this type Architecture where a client requests services and the
server responds to those requests. The server directly responds to the client.

 The Three Tier Architecture: This architecture contains an additional server, called the
application server, between client and database server. The application server reduces the
workload of the database server, thereby making application processing efficient. Its more secure
bcoz client cant access database directly. but its more complex to build and cant access data
directly.

Multi Station Access Unit (MAU)


⚫ A Media Access Unit (MAU), also known as a Multistation Access Unit (MAU or MSAU) is a
device to attach multiple network stations in a star topology as a token ring network, internally
wired to connect the stations into a logical ring.

⚫ A typical MAU might provide 8 or 16 ports for connecting stations to the ring. If a larger LAN is
required, you can join MAUs to form a larger ring by connecting the ring-out connector of one MAU
to the ring-in connector of another, and continue connecting until the ring-out of the last MAU in a
series is connected to the ring-in of the first to complete the loop. You can connect up to 33 MAUs in
this manner in a logical ring. MAUs also include circuitry that provides fault tolerance if a station
fails or is disconnected from the MAU and allows Token Ring traffic to continue around the ring
unaffected.

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Hub
A multiport repeater with more than one output port
⚫ Multiple data ports

⚫ Operate at Physical layer

⚫ Uplink port: allows connection to another hub or other connectivity device

⚫ On Ethernet networks, can serve as central connection point of star or star-based


hybrid topology

⚫ On Token Ring networks, hubs are called Multi station Access Units (MAUs)

⚫ Connected devices share same amount of bandwidth and same collision domain

⚫ Logically or physically distinct Ethernet network segment on which all participating


devices must detect and accommodate data collisions

Bridges

 Connect two network segments

 Analyze incoming frames

 Make decisions about where to direct them based on each frame’s MAC address

 Operate at Data Link layer

 Protocol independent and can move data more rapidly than traditional routers

 Extend Ethernet network without extending collision domain or segment

 Can be programmed to filter out certain types of frames

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Switches

⚫ Subdivide network into smaller logical pieces (segments)

⚫ Can operate at levels 2, 3, or 4 of OSI model

⚫ Multiport bridges

⚫ Most have internal processor, OS, memory, and several ports

⚫ Each port on switch acts like bridge

⚫ Each connected device effectively receives own dedicated channel

Modem
⚫ A modem (modulator–demodulator) is a network hardware device that modulates one or more carrier
wave signals to encode digital information for transmission and demodulates signals to decode the
transmitted information. The goal is to produce a signal that can be transmitted easily and decoded to
reproduce the original digital data.

⚫ Modems are generally classified by the maximum amount of data they can send in a given unit of time,
usually expressed in bits per second (symbol bit/s, sometimes abbreviated "bps"), or bytes per second
(symbol B/s

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Routers
⚫ Multiport connectivity devices that direct data between nodes on a network

⚫ Can integrate LANs and WANs

⚫ Running at different transmission speeds

⚫ Using variety of protocols

⚫ Reads incoming packet’s logical addressing information

⚫ Determines where to deliver packet

⚫ Determines shortest path to that network

⚫ Operate at Network layer

⚫ Protocol-dependent

⚫ Typical router has internal processor, OS, memory, various input and output jacks, and
management console interface

⚫ Modular router: multiple slots to hold different interface cards or other devices

Gateways
Connect two systems using different formatting, communications protocols, or architecture

 Repackage information to be read by another system

 Operates at multiple OSI Model layers

 E-mail gateway

 Internet gateway

 LAN gateway

 Voice/data gateway

 Firewall

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

TRANSMISSION MEDIA / CABLES

Network cable refers to a physical media that provides connectivity and communication between
network devices.

⚫ Transmission media is a pathway that carries the information from sender to receiver. We use
different types of cables or waves to transmit data. Data is transmitted normally through electrical
or electromagnetic signals.

CO-AXIAL CABLE

⚫ Coaxial cable, or coax is a type of electrical cable that has an inner conductor surrounded by a
tubular insulating layer, surrounded by a tubular conducting shield. Many coaxial cables also have an
insulating outer sheath or jacket.

Twisted pair Cable

⚫ Twisted pair cabling is a type of wiring in which two conductors of a single circuit are twisted
together for the purposes of canceling out electromagnetic interference (EMI) from external
sources;

STP shielded twisted pair

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Unshielded Twisted Pair (UTP).

FIBRE OPTIC CABLE

SMF & MMF

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

TOPOLOGIES

 Computer networks employ many different topologies or ways of connecting computers together.
Each topology has both pros and cons in regards to the way the cables and other pieces of
network hardware are connected to one another.
This section will be divided into 4 major categories. Within these sections, discussions of hybrid
topologies may take place.

1. Bus Topology 2.Ring Topology 3.Star Topology 4. Mesh Topology

BUS TOPOLOGY

Advantages of Bus Topology

• Easy to connect a computer or peripheral to a linear bus.

• Requires less cable length than a star topology.

Disadvantages of Bus Topology

• Entire network shuts down if there is a break in the main cable.

• Terminators are required at both ends of the backbone cable.

• Difficult to identify the problem if the entire network shuts down.

• Not meant to be used as a stand-alone solution.

RING TOPOLOGY

A ring network is a network topology in which each node connects to exactly two other nodes, forming a
single continuous pathway for signals through each node - a ring. Data travels from node to node, with
each node along the way handling every packet.

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Advantages of Ring Topology


1) This type of network topology is very organized. Each node gets to send the data when it receives an
empty token. This helps to reduces chances of collision. Also in ring topology all the traffic flows in
only one direction at very high speed.
2) Even when the load on the network increases, its performance is better than that of Bus topology.
3) There is no need for network server to control the connectivity between workstations.
4) Additional components do not affect the performance of network.
5) Each computer has equal access to resources.

Disadvantages of Ring Topology


1) Each packet of data must pass through all the computers between source and destination. This
makes it slower than Star topology.
2) If one workstation or port goes down, the entire network gets affected.
3) Network is highly dependent on the wire which connects different components.
4) MAU’s and network cards are expensive as compared to Ethernet cards and hubs.

STAR TOPOLOGY

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Alternatively referred to as a star network, star topology is one of the most common network setups.
In this configuration, every node connects to a central network device, like a hub, switch, or computer.
The central network device acts as a server and the peripheral devices act as clients. Depending on the
type of network card used in each computer of the star topology,STP/UTP network cable is used to
connect computers together.

Advantages of Star Topology

1) As compared to Bus topology it gives far much better performance, signals don’t necessarily get
transmitted to all the workstations. A sent signal reaches the intended destination after passing
through no more than 3-4 devices and 2-3 links. Performance of the network is dependent on
the capacity of central hub.
2) Easy to connect new nodes or devices. In star topology new nodes can be added easily
without affecting rest of the network. Similarly components can also be removed easily.
3) Centralized management. It helps in monitoring the network.
4) Failure of one node or link doesn’t affect the rest of network. At the same time its easy to
detect the failure and troubleshoot it.
Disadvantages of Star Topology

1) Too much dependency on central device has its own drawbacks. If it fails whole network
goes down.
2) The use of hub, a router or a switch as central device increases the overall cost of the network
3) Performance and as well number of nodes which can be added in such topology is depended
on capacity of central device.

MESH TOPOLOGY

The mesh topology incorporates a unique network design in which each computer on the network
connects to every other, creating a point-to-point connection between every device on the network. The
purpose of the mesh design is to provide a high level of redundancy. If one network cable fails, the
data always has an alternative path to get to its destination

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

TREE TOPOLOGY

A tree topology is a special type of structure in which many connected elements are arranged like the
branches of a tree. For example, tree topologies are frequently used to organize the computers in a
corporate network, or the information in a database.
In a tree topology, there can be only one connection between any two connected nodes. Because any two
nodes can have only one mutual connection, tree topologies form a natural parent-child hierarchy.

HYBRID TOPOLOGY

Application layer protocols

⚫ (Session Layer under OSI model) The IETF definition document for the application layer in the
Internet Protocol Suite is RFC 1123. It provided an initial set of protocols that covered the
major aspects of functionality of the early Internet.

⚫ Remote login to hosts: Telnet

⚫ File transfer: File Transfer Protocol (FTP), Trivial File Transfer Protocol (TFTP)

⚫ Electronic mail transport: Simple Mail Transfer Protocol (SMTP)

⚫ Networking support: Domain Name System (DNS)

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

⚫ Host initialization: BOOTP

⚫ Remote host management: Simple Network Management Protocol (SNMP), Common Management
Information Protocol over TCP (CMOT)

Ethernet

⚫ The Institute for Electrical and Electronic Engineers developed an Ethernet standard known as IEEE
Standard 802.3. This standard defines rules for configuring an Ethernet network and also specifies
how the elements in an Ethernet network interact with one another.

⚫ One of the most commonly used LAN technology.

⚫ It was established by DIX (DECnet, Intel, Xerox Corp).

⚫ Later standardised by IEEE 802.3 group.

⚫ The data will be transmitted in bits per second.

Internet Protocols

IP address is logical address used to communicate with systems in the network or internetwork.
An Internet Protocol address (IP address) is a numerical label assigned to each device connected to
a computer network that uses the Internet Protocol for communication.[1] An IP address serves two
principal functions: host or network interface identification and location addressing.
IP address is an 32 bit logical address which are assigned as binary numbers, The 32 Bits are divided
into 4 Octets, ( Octete is group of 8-bits). IP address will be assigned to each and every system in a
network. Without IP address communication is not possible.
Ex 00000000.00000000.00000000.00000000

The IP address is divided into two parts

1> Network ID : This ID identifies the network to which the host is connected. This is same for all the
host on a particular network.
2> Host ID : Identifies the host on the network. Host ID is different hosts on the network.
Classes of IP Address

Routing

IP addresses are classified into several classes of operational characteristics: unicast, multicast, anycast
and broadcast addressing.

DNS
⚫ The domain name system (DNS) is chiefly used to translate hostnames into numeric IP addresses

⚫ DNS is an example of a distributed database

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

⚫ If that server can resolve the hostname, it does so

⚫ If not, that server asks another domain name server

DHCP

⚫ Dynamic Host Configuration Protocol (DHCP) is a client/server protocol that automatically


provides an Internet Protocol (IP) host with its IP address and other related configuration
information such as the subnet mask and default gateway. RFCs 2131 and 2132 define DHCP as an
Internet Engineering Task Force (IETF) standard based on Bootstrap Protocol (BOOTP), a protocol
with which DHCP shares many implementation details. DHCP allows hosts to obtain required
TCP/IP configuration information from a DHCP server.

Wireless Networking

Wireless Networking is becoming more and more common in schools. Wireless Networking provides
flexibility for users without the limitations of wires.
.

Wireless Access Points (WAPs)

In computer networking, a Wireless Access Point (WAP) is a device that allows wireless
communication devices to connect to a wireless network using Wi-Fi, Bluetooth or related standards. The
WAP usually connects to a router, and can relay data between the wireless devices (such as computers or
printers) and wired devices on the network.

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Wireless Extension Points (WEPs)

Using a wireless range extender is one of the easiest ways to improve range. These products repeat
your existing wireless signal, giving you better Wi-Fi range without having to use any physical cabling. For
the best results, you have to place the extender halfway between the existing router and the area you get poor
reception.

Wireless Network Interface Cards (WNICs)

A wireless network interface card (WNIC) is a network card which connects to a radio-based computer
network. A WNIC, just like a NIC, works on the Layer 1 and Layer 2 of the OSI Model. A WNIC is an
essential component for wireless desktop/laptop computer. This card uses an antenna to communicate through
microwaves. A WNIC in a desktop computer usually is connected using the PCI bus. Other connectivity
options are USB and PC card. Integrated WNICs are also available.
Wireless Network Interface Cards and Wireless Access Points are designed to work at certain
specifications based on the IEEE. The most popular wireless specifications in 2010 are 802.11g (Wireless
G) and 802.11n (Wireless N). .

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

INTRODUCTION TO LINUX

The Open Standards Foundation is a UNIX industry organization designed to keep the various UNIX
flavors working together. They created operating systems guidelines called POSIX to encourage inter-
operability of applications from one flavor of UNIX to another. Portability of applications to different
gave UNIX a distinct advantage over its mainframe competition.

During the late 1990’s Microsoft’s Windows NT operating system started encroaching into traditional
UNIX businesses such as banking and high-end graphics. Although not as reliable as UNIX, NT
became popular because of the lower learning curve and its similarities to Windows 95 and 98. Many
traditional

UNIX companies, such as DEC and Silicon Graphics, abandoned their OS for NT. Others, such as
SUN, focused their efforts on niche markets, such as the Internet.

UNIX Principles
 Everything is a file:- UNIX system have many powerful utilities designed to create and
manipulate files. The UNIX security model is based around the security of files. By treating
everything as a file, you can secure access to hardware in the same way as you secure access
to a document.
 Configuration data stored in text: - Storing configuration in text allows an administrator to
move a configuration from one machine to another easily, provide the ability to roll back a
system configuration to a particular date and time.
 Small, Single-Purpose Programs: - UNIX provides many utilities.
 Ability to chain programs together to perform complex tasks:-A core design feature of
UNIX is that output of one program can be the input for another. This gives the user the
flexibility to combine many small programs together to perform a larger, more complex task.
Linux Origins
 LINUSTORVALDS
 Finnish college student in1991
 Created LinuxKernel
 When Linux Kernel combined with GNU applications, complete free UNIX like OS
was developed.

Why Linux?
1) Linux is a UNIX like OS: Linux is a similar to UNIX as the various UNIX versions are to
each other.
2) Multi-User and Multi-tasking: Linux is a multi-user and multi-tasking operating system. That
means that more than one person can be logged on to the same Linux computer at the same
time. The same user could even be logged into their account from two or more terminals at the
same time; Linux is also Multi-Tasking. A user can have more than one program executing at
the sametime.

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

3) Wide hardware support: Red Hat Linux support most pieces modern x86 compatible PC
hardware.
4) Fully Supported: Red Hat Linux is a fully supported distribution Red Hat Inc. provides many
support programs for the smallest to the largest companies.

FILESYSTEM HIERARCHY SYSTEM

Linux uses single rooted, inverted tree like file system


hierarchy
• / This is top leveldirectory
• It is parent directory for all other
directories It is called as ROOT
directory
• It is represented by
forward slash (/) C:\ of
windows

• /root it is home directory for root user (super user) It


provides working environment for root user C:\
Documents and Settings\Administrator

• /home it is home directory for other users


It provide working environment for other users (other than root) c:\
Documents and Settings\username

• /boot it contains bootable files for Linux


Like vmlinuz(kernel). ntoskrnl
Initrd (INITial Ram Disk)and
GRUB (GRand UnifiedBoot loader).
boot.ini,ntldr

• /etc it contains all configuration files


Like /etc/passwd..... Userinfo
/etc/resolv.conf... PreferredDNS
/etc/dhcpd.conf DHCPserver
C:\windows\system32\dirvers\

• /usr by default software’s are installed in /usr directory


(UNIXSharableResources)
c:\programfiles

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

• /opt It is optional directory for /usr It contains third party softwares c:\
programfiles

• /bin it contains commands used by all users (Binary files)

• /sbin it contains commands used by only Super User (root) (Super user's binary
files)

• /dev it contains device files


Like: /dev/had for HARD DISK
/dev/cdrom for CD ROM
Similar to device manager of windows

• /proc it contain process files


Its contents are not permanent, they keep changing It is also called
as Virtual Directory
Its file contain useful information used by OS
Like: /proc/meminfo information of RAM/SWAP
/proc/cpuinfo information of CPU

• /var it is containing variable data like mails, log files

• /mnt it is default mount point for any partition It is empty by default

• /media it contains all of removable media like CD-ROM, pen drive

• /lib it contains library files which are used by OS It is similar to dll files of
windows
Library files in Linux are SO (shared object) files

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

RHEL 6 BASIC GRAPHICAL INSTALLATION


Minimum and Recommended Requirements to install RHEL 6 are:

Recommended Minimum Recommended Minimum


Hardware Requirement Requirement Requirement Requirement
for for for for
RHEL6-32BIT RHEL6-32 BIT RHEL6-64BIT RHEL6-
64BIT
PROCESSOR AMD/INTEL AMD/INTEL P AMD/INTEL AMD/INTEL
DUALCORE IV CORE 2 DUO DUALCORE
MOTHER NORMAL NORMAL VT ENABLED VT
BOARD ENABLED
RAM 1 GB 384-512 MB 2 GB 768-1GB
HARD DISK 20 GB 15 GB 40 GB 20 GB

Partition Size For 32 Size For 64


Name Bit Bit
/ (root) 8 to 10 GB 15 to 20 GB
/boot 200 MB 200 MB
Twice of Twice of
SWAP RAM RAM

Installing RHEL6 with above specification

 Enter into BIOS setting and make CD/DVD Drive as first boot device
 Make sure that VT (Virtual Technology) is enabled for RHEL6-64 bit systems
 Insert the RHEL 6 CD/DVD into CD/DVD drive and boot the system
 If booted from CD/DVD Rom the following screen will be displayed

 Move the cursor to Install or upgrade an existing system and press Enter

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

 To test the media select OK, to skip the testing move cursor to Skip and press enter

 Click on Next button to move forward

 Select the keyboard type as required usually U.S English, click Next to continue

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

 Select the type of storage for the Computer. Click Next to continue

 Assign a hostname to the system, if wish to give ip address click on Configure Network, else
Click Next to continue.

 Select the nearest city in your Time Zone and Click on Next to continue

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

 Assign some password for root, then click on Next to continue

 Select the type of partitioning you want, to create your own partitions with custom sizes,
select Create Custom Layout and click on Next to continue

 Select /boot from Mount Point Box, give the size 200 MB for it and click on OK to create it.
 Repeat the same steps and create swap space
 This time select swap from File System Type, give the size required and click on OK

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

 Verify the partition and click on Next to continue with it.


 Click on Write changes to disk to continue, if wish make changes click on Go back
 To keep all as default, just click on Next button to continue
 Select Desktop to have a graphical environment in RHEL6.
 Check Customize later to install additional software later. Click on Next to continue

 Now sit back and relax until the installation is completed.

 Click on Forward to move to next step


 Accept the license agreement and click on Forward to continue
 Check No, I prefer to register at a later time. to skip the registration and click on Forward.
 Click on No thanks, to move to next step
 Click on Forward to continue
 Give a name to create a user and assign it a password. Click on Forward to continue.
 Click on Finish and congratulation your installation is now completed.
 Login using either kt user or root user.

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

BASIC COMMANDS
Creating, Removing, Copying, Moving files & Directories

Creating a file in Linux Using cat command:


 cat (Concatenate) command is used to create a file and to display and modify the contents of a file.
 To create a file
# cat> filename (say ktfile)
Hello World
Ctrl+d (To save the file)

To display the content of the file


# cat filename (say ktfile)

To append the data in the already existing file

# cat>><filename> # cat
>>ktfile Ctrl+d(to save the
changes)

Creating multiple files at same time using touch command

#touch <filename><filename><filename>
#touch file1 file2file3

Note: to check the files use # lscommand

Creating a Directory

#mkdir<dir name> #mkdirktdir


2021- Government Polytechnic
Government Polytechnic
Dept: computer Institute

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Making multiple directories inside a directory


Let us make some directories according to the following architecture in one command.

KernelTech

Linux Aix Storage

advlinuxlinuxclstr hacmplpar San, netapp

#mkdir –p KernelTech/{Linux/{advlinux,linuxclstr},Aix/{hacmp,lpar},Storage/{san,netapp}}

Check it by using tree command or ls –R command

Copying files into directory


#cp<source filename><destination directory in which to paste the file>
#cp file1 ktdir

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Copying directories from one location to other


# cp –rvfp<dir name><destination name>
#cp –rvfp ktdir2 ktdir

Moving files from one location to other (cut and Paste)


#mv <filename><Destination directory>
#mv file2 ktdir

Moving a Directory from one location to other

#mv <dir name><destination dir


name> #mv ktdir ktdir2

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Renaming a File
#mv <old name><new
name> #mv ktfilekernelfile

Renaming a Directory
 The procedure and command for renaming the directory is exactly same as renaming a file.

#mv old name new


name #mv
ktdirkerneldir

Removing a File

#rm filename or
#rm –f filename (without prompting)

Without prompting

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Removing an Empty directory


#rmdirdirname

Removing a directory with files or directories inside


A dir which is having some contents inside it cannot be removed by rmdir command. There are two ways to
delete the directory with contents.
i. Remove the contents inside the directory and then run rmdir command
ii. Run #rm –rfdirname(where r stands for recursive and f stands for forcefully.

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Arduino Mega 2560 Board


Arduino board is an open-source microcontroller board which is based on Atmega 2560
microcontroller. The growth environment of this board executes the processing or wiring language. These
boards have recharged the automation industry with their simple to utilize platform wherever everybody
with small otherwise no technical backdrop can start by discovering some necessary skills to program as
well as run the Arduino board. These boards are used to extend separate interactive objects otherwise we
can connect to software on your PC like MaxMSP, Processing, and Flash. This article discusses
an introduction to Arduino mega 2560 board, pin diagram and its specifications.
What is an Arduino Mega 2560?

The microcontroller board like “Arduino Mega” depends on the ATmega2560 microcontroller. It includes
digital input/output pins-54, where 16 pins are analog inputs, 14 are used like PWM outputs hardware
serial ports (UARTs) – 4, a crystal oscillator-16 MHz, an ICSP header, a power jack, a USB connection, as
well as an RST button. This board mainly includes everything which is essential for supporting the
microcontroller. So, the power supply of this board can be done by connecting it to a PC using a USB
cable, or battery or an AC-DC adapter. This board can be protected from the unexpected electrical
discharge by placing a base plate.

The SCL & SDA pins of Mega 2560 R3 board connects to beside the AREF pin. Additionally, there are
two latest pins located near the RST pin. One pin is the IOREF that permit the shields to adjust the voltage
offered from the Arduino board. Another pin is not associated & it is kept for upcoming purposes. These
boards work with every existing shield although can adjust to latest shields which utilize these extra pins.

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Arduino Mega Specifications


The specifications of Arduino Mega include the following.

 The ATmega2560 is a Microcontroller


 The operating voltage of this microcontroller is 5volts
 The recommended Input Voltage will range from 7volts to 12volts
 The input voltage will range from 6volts to 20volts
 The digital input/output pins are 54 where 15 of these pins will supply PWM o/p.
 Analog Input Pins are 16
 DC Current for each input/output pin is 40 mA
 DC Current used for 3.3V Pin is 50 mA
 Flash Memory like 256 KB where 8 KB of flash memory is used with the help of boot loader
 The static random access memory (SRAM) is 8 KB
 The electrically erasable programmable read-only memory (EEPROM) is 4 KB
 The clock (CLK) speed is 16 MHz
 The USB host chip used in this is MAX3421E
 The length of this board is 101.52 mm
 The width of this board is 53.3 mm
 The weight of this board is 36 g

Arduino Mega Pin Configuration


The pin configuration of this Arduino mega 2560 board is shown below. Every pin of this board comes
by a particular function which is allied with it. All analog pins of this board can be used as digital I/O pins.
By using this board, the Arduino mega projected can be designed. These boards offer flexible work memory
space is the more & processing power that permits to work with different types of sensors without delay.
When we compare with other types of Arduino boards, these boards are physically superior.

Arduino-mega 2560-board-pin-diagram

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Pin 3.3V & 5V


These pins are used for providing o/p regulated voltage approximately 5V. This RPS (regulated power
supply) provides the power to the microcontroller as well as other components which are used over the
Arduino mega board. It can be attained from Vin-pin of the board or one more regulated voltage supply-5V
otherwise USB cable, whereas another voltage regulation can be offered by 3.3V0-pin. The max power can
be drawn by this is 50mA.
GND Pin
The Arduino mega board includes 5-GND pins where one of these pins can be used whenever the
project requires.
Reset (RST) Pin
The RST pin of this board can be used for rearranging the board. The board can be rearranged by
setting this pin to low.
Vin Pin
The range of supplied input voltage to the board ranges from 7volts to 20volts. The voltage provided
by the power jack can be accessed through this pin. However, the output voltage through this pin to the
board will be automatically set up to 5V.

Serial Communication
The serial pins of this board like TXD and RXD are used to transmit & receive the serial data. Tx
indicates the transmission of information whereas the RX indicates receive data. The serial pins of this
board have four combinations. For serial 0, it includes Tx (1) and Rx (0), for serial 1, it includes Tx (18) &
Rx(19), for serial 2 it includes Tx (16) & Rx(17), and finally for serial 3, it includes Tx (14) & Rx(15).

EXTERNAL INTERRUPTS
The external interrupts can be formed by using 6-pins like interrupt 0(0), interrupt 1(3), interrupt
2(21), interrupt 3(20), interrupt 4(19), interrupt 5(18). These pins produce interrupts by a number of ways
i.e. Providing LOW value, rising or falling edge or changing the value to the interrupt pins.

LED
This Arduino board includes a LED and that is allied to pin-13 which is named as digital pin 13. This
LED can be operated based on the high and low values of the pin. This will give you to modify the
programming skills in real time.

AREF
The term AREF stands for Analog Reference Voltage which is a reference voltage for analog inputs.

ANALOG PINS
There are 16-analog pins included on the board which is marked as A0-A15. It is very important to
know that all the analog pins on this board can be utilized like digital I/O pins.

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

I2C
The I2C communication can be supported by two pins namely 20 & 21 where 20-pin signifies Serial Data
Line (SDA) which is used for holding the data & 21-pin signifies Serial Clock Line (SCL) mostly utilized
for offering data synchronization among the devices.

SPI Communication
The term SPI is a serial peripheral interface which is used to transmit the data among the controller &
other components. Four pins like MISO (50), MOSI (51), SCK (52), and SS (53) are utilized for the
communication of SPI.

Dimensions
The dimension of Arduino Mega 2560 board mainly includes the length as well as widths like 101.6mm
or 4 inch X 53.34 mm or 2.1 inches. It is comparatively superior to other types of boards which are
accessible in the marketplace. But, the power jack and USB port are somewhat expanded from the specified
measurements.

Shield Compatibility
Arduino Mega is well-suited for most of the guards used in other Arduino boards. Before you propose to
utilize a guard, confirm the operating voltage of the guard is well-suited with the voltage of the board. The
operating voltage of most of the guards will be 3.3V otherwise 5V. But, guards with high operating voltage
can injure the board.
In addition, the distribution header of the shield should vibrate with the distribution pin of the Arduino
board. For that, one can connect the shield simply with the Arduino board & make it within a running state.

Programming
The programming of an Arduino Mega 2560 can be done with the help of an IDE (Arduino Software),
and it supports C-programming language. Here the sketch is the code in the software which is burned within
the software and then moved to the Arduino board using a USB cable.
An Arduino mega board includes a boot loader which eliminates an external burner utilization to burn the
program code into the Arduino board. Here, the communication of the boot loader can be done using an
STK500 protocol.

When we compile as well as burn the Arduino program, then we can detach the USB cable to remove the
power supply from the Arduino board. Whenever you propose to use the Arduino board for your project, the
power supply can be provided by a power jack otherwise Vin pin of the board.
Another feature of this is multitasking wherever Arduino mega board comes handy. But, Arduino IDE
Software doesn’t support multi-tasking however one can utilize additional operating systems namely RTX &
Free RTOS to write C-program for this reason. This is flexible to use in your personal custom build program
with the help of an ISP connector.

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Technical Specifications

Microcontroller ATmega2560
Operating Voltage 5V Input
Voltage (recommended) 7-12V Input
Voltage (limits) 6-20V
Digital I/O Pins 54 (of which 14 provide PWM output)
Analog Input Pins 16
DC Current per I/O Pin 40 mA
DC Current for 3.3V Pin 50 mA
Flash Memory 256 KB of which 8 KB used by bootloader
SRAM 8 KB
EEPROM 4 KB
Clock Speed 16 MHz

How To Use Arduino?


Arduino can sense the environment by receiving input from a variety of sensors and can affect its
surroundings by controlling lights, motors, and other actuators. The microcontroller on the board is
programmed using the Arduino programming language (based on Wiring) and the Arduino development
environment (based on Processing). Arduino projects can be stand-alone or they can communicate with
software on running on a computer (e.g. Flash, Processing, MaxMSP).

Arduino is a cross-platform program.

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Now you’re actually ready to “burn” your first program on the arduino board. To select “blink led”, the physical tran

File>Sketchbook> Arduino- 0017>Examples> Digital>Blink

Once you have your sketch you’ll see something very close to the screenshot on the right.
In Tools>Board select MEGA Now you have to go to
Tools>Serial Port
and select the right serial port, the one arduino is attached to.

Analog Read Serial


This example shows you how to read analog input from the physical world using a potentiometer.
A potentiometer is a simple mechanical device that provides a varying amount of resistance when its shaft
is turned. By passing voltage through a potentiometer and into an analog input on your board, it is possible
to measure the amount of resistance produced by a potentiometer (or pot for short) as an analog value. In
this example you will monitor the state of your potentiometer after establishing serial communication
between your Arduino or Genuino and your computer running the Arduino Software (IDE).

Hardware Required
 Arduino or Genuino Board
 10k ohm Potentiometer

Circuit
Connect the three wires from the potentiometer to your board. The first goes from one of the outer pins
of the potentiometer to ground . The second goes from the other outer pin of the potentiometer to 5 volts.
The third goes from the middle pin of the potentiometer to the analog pin A0.

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

By turning the shaft of the potentiometer, you change the amount of resistance on either side of the
wiper, which is connected to the center pin of the potentiometer. This changes the voltage at the center pin.
When the resistance between the center and the side connected to 5 volts is close to zero (and the
resistance on the other side is close to 10k ohm), the voltage at the center pin nears 5 volts. When the
resistances are reversed, the voltage at the center pin nears 0 volts, or ground. This voltage is the analog
voltage that you're reading as an input.
The Arduino and Genuino boards have a circuit inside called an analog-to-digital converter or ADC that
reads this changing voltage and converts it to a number between 0 and 1023. When the shaft is turned all
the way in one direction, there are 0 volts going to the pin, and the input value is 0. When the shaft is
turned all the way in the opposite direction, there are 5 volts going to the pin and the input value is 1023. In
between, analogRead() returns a number between 0 and 1023 that is proportional to the amount of voltage
being applied to the pin.

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Code
In the sketch below, the only thing that you do in the setup function is to begin serial communications, at
9600 bits of data per second, between your board and your computer with the command:
Serial.begin(9600);

Next, in the main loop of your code, you need to establish a variable to store the resistance value (which
will be between 0 and 1023, perfect for an int datatype) coming in from your potentiometer: int
sensorValue = analogRead(A0);
Finally, you need to print this information to your serial monitor window. You can do this with the
command Serial.println() in your last line of code: Serial.println(sensorValue)
Now, when you open your Serial Monitor in the Arduino Software (IDE) (by clicking the icon that looks like
a lens, on the right, in the green top bar or using the keyboard shortcut Ctrl+Shift+M), you should see a
steady stream of numbers ranging from 0-1023, correlating to the position of the pot. As you turn your
potentiometer, these numbers will respond almost instantly.

Sample Code
/*
AnalogReadSerial
Reads an analog input on pin 0, prints the result to the Serial Monitor.
Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
This example code is in the public domain.
*/
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// print out the value you
read:
Serial.println(sensorValue);
delay(1); // delay in between reads for stability
}

se t up()
Description

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

The setup() function is called when a sketch starts. Use it to initialize variables, pin modes, start
using libraries, etc. The setup() function will only run once, after each power up or reset of the
Arduino board.
Example Code
int buttonPin = 3;

voidsetup() {
Serial.begin(9600);
pinMode(buttonPin,
INPUT);
}

voidloop() {
// ...
loop()

[Sketch]
Description
After creating a setup() function, which initializes and sets the initial values,
the loop() function does precisely what its name suggests, and loops consecutively, allowing your
program to change and respond. Use it to actively control the Arduino board.

Example Code
int buttonPin = 3;

// setup initializes serial and the button


pin voidsetup() {
Serial.begin(9600);
pinMode(buttonPin,
INPUT);
}

// loop checks the button pin each time,


// and will send serial if it is
pressed voidloop() {
if (digitalRead(buttonPin) == HIGH)
{ Serial.write('H');
}
else {
Serial.write('L
');
}

analogRead()
[Analog I/O]

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Description
Reads the value from the specified analog pin. Arduino boards contain a multichannel, 10 -bit analog
to digital converter. This means that it will map input voltages between 0 and the operating
voltage(5V or 3.3V) into integer values between 0 and 1023. On an Arduino UNO, for example, this
yields a resolution between readings of: 5 volts / 1024 units or, 0.0049 volts (4.9 mV) per unit. See
the table below for the usable pins, operating voltage and maximum resolution for some Arduino
boards.
The input range can be changed using analogReference(), while the resolution can be changed (only
for Zero, Due and MKR boards) using analogReadResolution().
On ATmega based boards (UNO, Nano, Mini, Mega), it takes about 100 microseconds (0.0001 s) to
read an analog input, so the maximum reading rate is about 10,000 times a second.

*A0 through A5 are labelled on the board, A6 through A11 are respectively available on pins 4, 6, 8,
9, 10, and 12
**The default analogRead() resolution for these boards is 10 bits, for compatibility. You need to
use analogReadResolution() to change it to 12 bits.

Notes and Warnings


If the analog input pin is not connected to anything, the value returned by analogRead() will fluctuate
based on a number of factors (e.g. the values of the other analog inputs, how close your hand is to the
board, etc.).
BOARD OPERATING VOLTAGE USABLE PINS MAX RESOLUTION

Uno 5 Volts A0 to A5 10 bits

Mini, Nano 5 Volts A0 to A7 10 bits

Mega, Mega2560, 5 Volts A0 to A14 10 bits


MegaADK
Micro 5 Volts A0 to A11* 10 bits

Leonardo 5 Volts A0 to A11* 10 bits

Zero 3.3 Volts A0 to A5 12 bits**

Due 3.3 Volts A0 to A11 12 bits**

MKR Family boards 3.3 Volts A0 to A6 12 bits**

Syntax
analogRead(pin)

Parameters
pin: the name of the analog input pin to read from (A0 to A5 on most boards, A0 to A6 on MKR
boards, A0 to A7 on the Mini and Nano, A0 to A15 on the Mega).

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Returns
The analog reading on the pin. Although it is limited to the resolution of the analog to digital
converter (0-1023 for 10 bits or 0-4095 for 12 bits). Data type: int.

Example Code
The code reads the voltage on analogPin and displays it.
int analogPin = A3; // potentiometer wiper (middle terminal) connected to analog pin 3
// outside leads to ground and +5V
int val = 0; // variable to store the value read

voidsetup() { Serial.begin(9600);
} // setup serial

voidloop() {
val = analogRead(analogPin); // read the input pin Serial.println(val);// debug value
}

I n t [Data Types]

Description
Integers are your primary data-type for number storage.
On the Arduino Uno (and other ATmega based boards) an int stores a 16 -bit (2-byte) value. This
yields a range of -32,768 to 32,767 (minimum value of -2^15 and a maximum value of (2^15) - 1).
On the Arduino Due and SAMD based boards (like MKR1000 and Zero), an int stores a 32 -bit (4-
byte) value. This yields a range of -2,147,483,648 to 2,147,483,647 (minimum value of -2^31 and a
maximum value of (2^31) - 1).

Int store negative numbers with a technique called ( 2’s complement math). The highest bit,
sometimes referred to as the "sign" bit, flags the number as a negative number. The rest of the bits
are inverted and 1 is added.

The Arduino takes care of dealing with negative numbers for you, so that arithmetic operations work
transparently in the expected manner. There can be an unexpected complication in dealing with
the bit shift right operator (>>) however.

Syntax : int var = val;

Parameters

var: variable name.


val: the value you assign to that variable.

Example Code : This code val: creates an integer called 'countUp', which is initially set as the
number 0 (zero). The variable goes up by 1 (one) each loop, being displayed on the serial monitor.

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

int countUp = 0; //creates a variable integer called 'countUp'

voidsetup() {
Serial.begin(9600); // use the serial port to print the number
}

voidloop() {
countUp++; //Adds 1 to the countUp int on every loop
Serial.println(countUp); // prints out the current state of countUp
delay(1000);
}

Serial
[Communication]
BOARD USB CDC SERIAL PINS SERIAL 1 SERIAL 2 SERIAL 3 PINS
NAME PINS PINS
Uno, Nano, Mini 0(RX), 1(TX)

Mega 0(RX), 1(TX) 19(RX), 17(RX), 15(RX),


18(TX) 16(TX) 14(TX)
Leonardo, Micro, Serial 0(RX),
Yún 1(TX)
Uno WiFi Rev.2 Connected to 0(RX), Connecte
USB 1(TX) d to
NINA
MKR boards Serial 13(RX),
14(TX)
Zero Serial USB Connected to 0(RX),
(Native USB Programming 1(TX)
Port only) Port
Due Serial USB 0(RX), 1(TX) 19(RX), 17(RX), 15(RX),
(Native USB 18(TX) 16(TX) 14(TX)
Port only)
101 Serial 0(RX),
1(TX)
Description
Used for communication between the Arduino board and a computer or other devices. All Arduino
boards have at least one serial port (also known as a UART or USART), and some have several.
On Uno, Nano, Mini, and Mega, pins 0 and 1 are used for communication with the computer.
Connecting anything to these pins can interfere with that communication, including causing failed
uploads to the board.
You can use the Arduino environment’s built-in serial monitor to communicate with an Arduino
board. Click the serial monitor button in the toolbar and select the same baud rate used in the call
to begin().

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Serial communication on pins TX/RX uses TTL logic levels (5V or 3.3V depending on the
board). Don’t connect these pins directly to an RS232 serial port; they operate at +/- 12V and can
damage your Arduino board.
To use these extra serial ports to communicate with your personal computer, you will nee d an
additional USB-to-serial adaptor, as they are not connected to the Mega’s USB-to-serial adaptor.
To use them to communicate with an external TTL serial device, connect the TX pin to your
device’s RX pin, the RX to your device’s TX pin, and the ground of your Mega to your device’s
ground.

Functions
if(Serial)
available()
availableForWrite()
begin()
end()
find()
findUntil()
flush()
parseFloat()
parseInt()
peek()
print()
println()
read()
readBytes()
readBytesUntil()
readString()
readStringUntil()
setTimeout()
write()
serialEvent()

Bare Minimum code needed


This example contains the bare minimum of code you need for a sketch to compile properly on Arduino
Software (IDE): the setup() method and the loop() method.

Hardware Required
Arduino or Genuino Board

Circuit
Only your Arduino or Genuino Board is needed for this example.

image developed using Fritzing .

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Code

 The setup() function is called when a sketch starts. Use it to initialize variables, pin modes, start
using libraries, etc. The setup function will only run once, after each power up or reset of the
board.
 After creating a setup() function, the loop() function does precisely what its name suggests, and loops
consecutively, allowing your program to change and respond as it runs. Code in the loop() section of
your sketch is used to actively control the board.
 The code below won't actually do anything, but it's structure is useful for copying and pasting to
get you started on any sketch of your own. It also shows you how to make comments in your code.
 Any line that starts with two slashes (//) will not be read by the compiler, so you can write
anything you want after it. The two slashes may be put after functional code to keep comments on
the same line. Commenting your code like this can be particularly helpful in explaining, both to
yourself and others, how your program functions step by step.
/*
Blink

Turns 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 LED_BUILTIN as an output.


pinMode(LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again
forever void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage
LOW delay(1000); // wait for a second
}
/*
DigitalReadSerial

Reads a digital input on pin 2, prints the result to the Serial Monitor

This example code is in the public domain.

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

*/
// digital pin 2 has a pushbutton attached to it. Give it a
name: int pushButton = 2;

// the setup routine runs once when you press reset:


void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
// make the pushbutton's pin an input:
pinMode(pushButton, INPUT);
}

// the loop routine runs over and over again


forever: void loop() {
// read the input pin:
int buttonState = digitalRead(pushButton);
// print out the state of the
button:
Serial.println(buttonState);
delay(1); // delay in between reads for stability
}

Fade
This example demonstrates the use of the analogWrite() function in fading an LED off and on.
Analog Write uses pulse width modulation (PWM), turning a digital pin on and off very quickly with
different ratio between on and off, to create a fading effect.

Hardware Required

 Arduino or Genuino board


 LED
 220 ohm resistor
 hook-up wires
 breadboard

Circuit
Connect the anode (the longer, positive leg) of your LED to digital output pin 9 on your board through a
220 ohm resistor. Connect the cathode (the shorter, negative leg) directly to ground.

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Code
After declaring pin 9 to be your ledPin, there is nothing to do in the setup() function of your code.
The analogWrite() function that you will be using in the main loop of your code requires two arguments:
One telling the function which pin to write to, and one indicating what PWM value to write.
In order to fade your LED off and on, gradually increase your PWM value from 0 (all the way off) to 255
(all the way on), and then back to 0 once again to complete the cycle. In the sketch below, the PWM value
is set using a variable called brightness. Each time through the loop, it increases by the value of the
variable fade Amount.
If brightness is at either extreme of its value (either 0 or 255), then fade Amount is changed to its negative.
In other words, if fade Amount is 5, then it is set to -5. If it's -5, then it's set to 5. The next time through the
loop, this change causes brightness to change direction as well.
analogWrite() can change the PWM value very fast, so the delay at the end of the sketch controls the
speed of the fade. Try changing the value of the delay and see how it changes the fading effect.
/*
Fade
This example shows how to fade an LED on pin 9 using the analogWrite() function.
The analogWrite() function uses PWM, so if you want to change the pin you're using, be sure to use
another PWM capable pin. On most Arduino, the PWM pins are identified with a "~" sign, like ~3, ~5, ~6,
~9, ~10 and ~11.
*/
int led = 9; // the PWM pin the LED is attached
to int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by
// the setup routine runs once when you press reset:
void setup() {
// declare pin 9 to be an output:

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

pinMode(led, OUTPUT);
}
// the loop routine runs over and over again
forever: void loop() {
// set the brightness of pin 9:
analogWrite(led, brightness);
// change the brightness for next time through the
loop: brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the
fade: if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
// wait for 30 milliseconds to see the dimming
effect delay(30);
}

FUNCTIONS

For controlling the Arduino board and performing computations.

Digital I/O isAlpha()


digitalRead() Time isAlphaNumeric()
digitalWrite() delay() isAscii()
pinMode() delayMicroseconds() isControl()
micros() isDigit()
Analog I/O millis() isGraph()
analogRead()
isHexadecimalDigit()
analogReference() Math isLowerCase()
analogWrite() abs() isPrintable()
constrain() isPunct()
Zero, Due & MKR map()
Family isSpace()
max() isUpperCase()
analogReadResolution() min()
analogWriteResolution() isWhitespace()
pow()
sq() Random Numbers
Advanced I/O
sqrt() random()
noTone()
pulseIn() randomSeed()
pulseInLong() Trigonometry
shiftIn() cos() Bits and Bytes
shiftOut() sin() bit() bitClear()
tone() tan() bitRead()
Characters
2021- Government Polytechnic
Government Polytechnic
Dept: computer Institute

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

bitSet()
bitWrite() Interrupts
highByte() interrupts()
lowByte() USB
noInterrupts()
Keyboard
External Interrupts Communication Mouse
attachInterrupt() Serial
detachInterrupt() Stream

Variables ,Arduino data types and constants .


Constants long() unsigned char
Floating Point Constants word() unsigned int
Integer Constants unsigned long
HIGH | LOW Data Types void
INPUT | OUTPUT | INPUT_P word
String()
ULLUP
LED_BUILTIN array
bool Variable Scope & Qualifiers
true | false
boolean const
byte scope
Conversion char static
double volatile
(unsigned int) float
(unsigned long) int Utilities
byte() long PROGMEM
char() short sizeof()
float() size_t
int() string

STRUCTURE

The elements of Arduino (C++) code.

switch...case * (multiplication)
Sketch
while + (addition)
loop() - (subtraction)
setup() Further Syntax / (division)
#define (define) = (assignment operator)
Control Structure #include (include)
break /* */ (block comment) Comparison Operators
continue // (single line comment) != (not equal to)
do...while ; (semicolon) < (less than)
else {} (curly braces) <= (less than or equal to)
for
== (equal to)
goto Arithmetic Operators
> (greater than)
if % (remainder) >= (greater than or equal to)
return
2021- Government Polytechnic
Government Polytechnic
Dept: computer Institute

2021- Government Polytechnic


Government Polytechnic
Dept: computer Institute

Boolean Operators Bitwise Operators *= (compound multiplication)


! (logical not) & (bitwise and) ++ (increment)
&& (logical << (bitshift left) += (compound addition)
and) >> (bitshift right) -- (decrement)
|| (logical or) ^ (bitwise xor) -= (compound subtraction)
| (bitwise or) /= (compound division)
~ (bitwise not) ^= (compound bitwise xor)
Pointer Access Operators |= (compound bitwise or)
& (reference operator) Compound Operators
* (dereference operator) %= (compound remainder)
&= (compound bitwise and)

Blink Without Delay



Sometimes you need to do two things at once. For example you might want to blink an LED
while reading a button press. In this case, you can't use delay(), because Arduino pauses your
program during the delay(). If the button is pressed while Arduino is paused waiting for the
delay() to pass, your program will miss the button press.
 This sketch demonstrates how to blink an LED without using delay(). It turns the LED on and then
makes note of the time. Then, each time through loop(), it checks to see if the desired blink time
has passed. If it has, it toggles the LED on or off and makes note of the new time. In this way the
LED blinks continuously while the sketch execution never lags on a single instruction.
 An analogy would be warming up a pizza in your microwave, and also waiting some
important email. You put the pizza in the microwave and set it for 10 minutes. The analogy to
using delay() would be to sit in front of the microwave watching the timer count down from 10
minutes until the timer reaches zero. If the important email arrives during this time you will miss it.
 What you would do in real life would be to turn on the pizza, and then check your email, and then
maybe do something else (that doesn't take too long!) and every so often you will come back to
the microwave to see if the timer has reached zero, indicating that your pizza is done.
Hardware Required
 Arduino or Genuino Board
 LED
 220 ohm resistor

Circuit

2021- Government Polytechnic


Government Polytechnic
Institute
HUBLI
To build the circuit, connect one end of the resistor to pin 13 of the board. Connect the long leg of the LED
(the positive leg, called the anode) to the other end of the resistor. Connect the short leg of the LED (the
negative leg, called the cathode) to the board GND, as shown in the diagram above and the schematic
below.
Most Arduino and Genuino boards already have an LED attached to pin 13 on the board itself. If you run
this example with no hardware attached, you should see that LED blink.
After you build the circuit plug your board into your computer, start the Arduino Software (IDE), and enter
the code below.

Code
The code below uses the millis() function, a command that returns the number of milliseconds since the
board started running its current sketch, to blink an LED.
/*
Blink without Delay
Turns on and off a light emitting diode (LED) connected to a digital pin,
without using the delay() function. This means that other code can run at the
same time without being interrupted by the LED code.
The circuit:
- Use the onboard LED.
- Note: Most Arduinos have an on-board LED you can control. On the UNO, MEGA
and ZERO it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN
is set to the correct LED pin independent of which board is used.
*/
// constants won't change. Used here to set a pin number:
const int ledPin = LED_BUILTIN;// the number of the LED pin

// Variables will change:


int ledState = LOW; // ledState used to set the LED

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0; // will store last time LED was updated

// constants won't change:


const long interval = 1000; // interval at which to blink (milliseconds)

void setup() {
// set the digital pin as output:
pinMode(ledPin, OUTPUT);
}
void loop() {
// here is where you'd put code that needs to be running all the time.
// check to see if it's time to blink the LED; that is, if the difference
// between the current time and last time you blinked the LED is bigger than
// the interval at which you want to blink the
LED. unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
// save the last time you blinked the LED

2020- Government Polytechnic


Government Polytechnic
Institute
HUBLI
previousMillis = currentMillis;
// if the LED is off turn it on and vice-
versa: if (ledState == LOW) {
ledState = HIGH;
} else {
ledState = LOW;
}
// set the LED with the ledState of the
variable: digitalWrite(ledPin, ledState);
}
}
Button
Pushbuttons or switches connect two points in a circuit when you press them. This example turns on
the built-in LED on pin 13 when you press the button.
Hardware

 Arduino or Genuino Board


 Momentary button or Switch
 10K ohm resistor
 hook-up wires
 breadboard

Circuit

Connect three wires to the board. The first two, red and black, connect to the two long vertical rows on the
side of the breadboard to provide access to the 5 volt supply and ground. The third wire goes from digital pin
2 to one leg of the pushbutton. That same leg of the button connects through a pull-down resistor (here 10K
ohm) to ground. The other leg of the button connects to the 5 volt supply.
When the pushbutton is open (un pressed) there is no connection between the two legs of the pushbutton,
so the pin is connected to ground (through the pull-down resistor) and we read a LOW. When the button is
closed (pressed), it makes a connection between its two legs, connecting the pin to 5 volts, so that we read a
HIGH.
You can also wire this circuit the opposite way, with a pull up resistor keeping the input HIGH, and going
LOW when the button is pressed. If so, the behaviour of the sketch will be reversed, with the LED
normally on and turning off when you press the button.
If you disconnect the digital I/O pin from everything, the LED may blink erratically. This is because the
input is "floating" - that is, it will randomly return either HIGH or LOW. That's why you need a pull-up or
pull-down resistor in the circuit.

2020- Government Polytechnic


Government Polytechnic
Institute
HUBLI

Code
/*
Button
Turns on and off a light emitting diode(LED) connected to digital pin 13,
when pressing a pushbutton attached to pin 2.

The circuit:
- LED attached from pin 13 to ground
- pushbutton attached to pin 2 from +5V
- 10K resistor attached to pin 2 from ground
- Note: on most Arduinos there is already an LED on the board attached to pin 13.
*/
// constants won't change. They're used here to set pin
numbers: const int buttonPin = 2; // the number of
the pushbutton pin const int ledPin = 13; // the number of
the LED pin

// variables will change:


int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an
input: pinMode(buttonPin, INPUT);
}
void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);

// check if the pushbutton is pressed. If it is, the buttonState is


HIGH: if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
} else {
// turn LED off:
digitalWrite(ledPin, LOW);
}}
2020- Government Polytechnic
Government Polytechnic
Institute
HUBLI

2020- Government Polytechnic


Government Polytechnic
Institute
HUBLI
Debounce
Pushbuttons often generate spurious open/close transitions when pressed, due to mechanical and physical
issues: these transitions may be read as multiple presses in a very short time fooling the program. This
example demonstrates how to debounce an input, which means checking twice in a short period of time to
make sure the pushbutton is definitely pressed. Without debouncing, pressing the button once may cause
unpredictable results. This sketch uses the millis() function to keep track of the time passed since the button
was pressed.

Hardware Required

 Arduino or Genuino Board


 momentary button or switch
 10k ohm resistor
 hook-up wires
 breadboard

Code
The sketch below is based on Limor Fried's version of debounce, but the logic is inverted from her example.
In her example, the switch returns LOW when closed, and HIGH when open. Here, the switch returns
HIGH when pressed and LOW when not pressed.
/*
Debounce
Each time the input pin goes from LOW to HIGH (e.g. because of a push-button
press), the output pin is toggled from LOW to HIGH or HIGH to LOW. There's a
minimum delay between toggles to debounce the circuit (i.e. to ignore noise).

2020- Government Polytechnic


Government Polytechnic
Institute
HUBLI
The circuit:
- LED attached from pin 13 to ground
- pushbutton attached from pin 2 to +5V
- 10 kilohm resistor attached from pin 2 to ground

- Note: On most Arduino boards, there is already an LED on the board connected to pin 13, so you
don't need any extra components for this example.
*/
// constants won't change. They're used here to set pin
numbers: const int buttonPin = 2; // the number
of the pushbutton pin const int ledPin = 13; // the number
of the LED pin
// Variables will change:
int ledState = HIGH; // the current state of the output pin
int buttonState; // the current reading from the input
pin
int lastButtonState = LOW; // the previous reading from the input pin
// the following variables are unsigned longs because the time, measured in
// milliseconds, will quickly become a bigger number than can be stored in an int.
unsigned long lastDebounceTime = 0; // the last time the output pin was toggled
unsigned long debounceDelay = 50; // the debounce time; increase if the output
flickers

void setup() {
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);

// set initial LED state


digitalWrite(ledPin, ledState);
}

void loop() {
// read the state of the switch into a local variable:
int reading = digitalRead(buttonPin);

// check to see if you just pressed the button


// (i.e. the input went from LOW to HIGH), and you've waited long enough
// since the last press to ignore any noise:

// If the switch changed, due to noise or


pressing: if (reading != lastButtonState) {
// reset the debouncing timer
lastDebounceTime = millis();
}

if ((millis() - lastDebounceTime) > debounceDelay) {


// whatever the reading is at, it's been there for longer than the debounce
// delay, so take it as the actual current state:

// if the button state has

2020- Government Polytechnic


Government Polytechnic
Institute
changed: if (reading != HUBLI
buttonState) { buttonState =
reading;

2020- Government Polytechnic


Government Polytechnic
Institute
HUBLI
// only toggle the LED if the new button state is
HIGH if (buttonState == HIGH) {
ledState = !ledState;
}
}
}// set the LED:
digitalWrite(ledPin, ledState);
// save the reading. Next time through the loop, it'll be the lastButtonState:
lastButtonState = reading;
}

Arrays

 This variation on the For Loop Iteration example shows how to use an array. An array is a variable
with multiple parts. If you think of a variable as a cup that holds values, you might think of an array
as an ice cube tray. It's like a series of linked cups, all of which can hold the same maximum value.
 The For Loop Iteration example shows you how to light up a series of LEDs attached to pins 2
through 7 of the Arduino or Genuino board, with certain limitations (the pins have to be numbered
contiguously, and the LEDs have to be turned on in sequence).
 This example shows you how you can turn on a sequence of pins whose numbers are neither
contiguous nor necessarily sequential. To do this is, you can put the pin numbers in an array and then
use for loops to iterate over the array.
 This example makes use of 6 LEDs connected to the pins 2 - 7 on the board using 220 ohm resistors,
just like in the For Loop. However, here the order of the LEDs is determined by their order in the
array, not by their physical order.
 This technique of putting the pins in an array is very handy. You don't have to have the pins
sequential to one another, or even in the same order. You can rearrange them in any order you want.

Circuit
Connect six LEDs, with 220 ohm resistors in series, to digital pins 2-7 on your board.

2020- Government Polytechnic


Government Polytechnic
Institute
HUBLI

Hardware Required

 Arduino or Genuino Board


 6 LEDs
 6 220 ohm resistors
 hook-up wires
 breadboard

Schematic:

Code
/*
Arrays
Demonstrates the use of an array to hold pin numbers in order to iterate over the pins in a sequence. Lights multiple

Unlike the For Loop tutorial, where the pins have to be contiguous, here the pins can be in any random order.

The circuit:
- LEDs from pins 2 through 7 to ground
*/

int timer = 100; int ledPins[]


// The higher
= { 2, 7,
the4,number,
6, 5, 3 the slower the timing.

};// an array of pin numbers to which LEDs are attached


int pinCount = 6;// the number of pins (i.e. the length of the array)

2020- Government Polytechnic


Government Polytechnic
Institute
HUBLI
void setup() {

// the array elements are numbered from 0 to (pinCount - 1).


// use a for loop to initialize each pin as an output:
for (int thisPin = 0; thisPin < pinCount; thisPin++) {
pinMode(ledPins[thisPin], OUTPUT);
}
}
void loop() {
// loop from the lowest pin to the highest:
for (int thisPin = 0; thisPin < pinCount; thisPin++) {
// turn the pin on:
digitalWrite(ledPins[thisPin], HIGH);
delay(timer);
// turn the pin off:
digitalWrite(ledPins[thisPin], LOW);
}
// loop from the highest pin to the lowest:
for (int thisPin = pinCount - 1; thisPin >= 0; thisPin--) {
// turn the pin on:
digitalWrite(ledPins[thisPin], HIGH);
delay(timer);
// turn the pin off:
digitalWrite(ledPins[thisPin], LOW);
}
}
For Loop Iteration (aka The Knight Rider)
LEDs in all possible sizes performing flashy effects. In particular, it had a display that scanned back and
forth across a line, as shown in this exciting fight between KITT and KARR Often you want to iterate over
a series of pins and do something to each one. For instance, this example blinks 6 LEDs attached to the
Arduino or Genuino by using a for() loop to cycle back and forth through digital pins 2-7. The LEDS are
turned on and off, in sequence, by using both the digitalWrite() and delay() functions .

We also call this example "Knight Rider" in memory of a TV-series from the 80's where David Hasselh off
had an AI machine named KITT driving his Pontiac. The car had been augmented with plenty of. This
example duplicates the KITT display.

Hardware Required

 Arduino or Genuino Board


 6 220 ohm resistors
 6 LEDs
 hook-up wires
 breadboard

Circuit
Connect six LEDS, with 220 ohm resistors in series, to digital pins 2-7 on your Arduino.

2020- Government Polytechnic


Government Polytechnic
Institute
HUBLI

Code
The code below begins by utilizing a for() loop to assign digital pins 2-7 as outputs for the 6 LEDs used.

In the main loop of the code, two for() loops are used to loop incrementally, stepping through the LEDs, one
by one, from pin 2 to pin seven. Once pin 7 is lit, the process reverses, stepping back down through each
LED.

/*
For Loop Iteration Demonstrates the use of a for() loop.Lights multiple LEDs in sequence, then in
reverse.
*/
int timer = 100; // The higher the number, the slower the timing.
void setup() {
// use a for loop to initialize each pin as an
output: for (int thisPin = 2; thisPin < 8; thisPin+
+) { pinMode(thisPin, OUTPUT);
}

2020- Government Polytechnic


Government Polytechnic
Institute
HUBLI
void loop() {
// loop from the lowest pin to the highest:

for (int thisPin = 2; thisPin < 8; thisPin++) {


// turn the pin on: digitalWrite(thisPin, HIGH); delay(timer);
// turn the pin off:
digitalWrite(thisPin, LOW);
}
// loop from the highest pin to the lowest:
for (int thisPin = 7; thisPin >= 2; thisPin--) {
// turn the pin on: digitalWrite(thisPin, HIGH); delay(timer);
// turn the pin off:
digitalWrite(thisPin, LOW);
}
}

If Statement (Conditional Statement)


The if() statement is the most basic of all programming control structures. It allows you to make something
happen or not, depending on whether a given condition is true or not. It looks like this:

if (someCondition) { // do stuff if the condition is true}

There is a common variation called if-else that looks like this:


if (someCondition) {
There's also the else-if, where you can check a second condition if the first is false:
// do stuff if the condition is true
if (someCondition) {
} else {
// do stuff if the condition is true
// do stuff if the condition is false
} else if (anotherCondition) {
}
// do stuff only if the first condition is false
// and the second condition is true
}
You'll use if statements all the time. The example below turns on an LED on pin 13 (the built-in LED on
many Arduino boards) if the value read on an analog input goes above a certain threshold.

Hardware Required

 Arduino or Genuino Board


 Potentiometer or variable resistor

2020- Government Polytechnic


Government Polytechnic
Institute
HUBLI
Circuit

Schematic

Code
In the code below, a variable called analogValue is used to store the data collected from a potentiometer
connected to the board on analogPin 0. This data is then compared to a threshold value. If the analog value is
found to be above the set threshold the built-in LED connected to digital pin 13 is turned on. If analogValue
is found to be < (less than) threshold, the LED remains off.

*/ Conditionals - If statement
 This example demonstrates the use of if() statements.
 It reads the state of a potentiometer (an analog input) and turns on an LED only if the
potentiometer goes above a certain threshold level. It prints the analog value regardless of the
level.

The circuit:
- potentiometer Center pin of the potentiometer goes to analog pin 0. Side pins of the potentiometer go to
+5V and ground.
- LED connected from digital pin 13 to ground
- Note: On most Arduino boards, there is already an LED on the board connected to pin 13, so you
don't need any extra components for this example.
*/
2020- Government Polytechnic
Government Polytechnic
Institute
HUBLI

2020- Government Polytechnic


Government Polytechnic
Institute
HUBLI
// These constants won't change:
const int analogPin = A0; // pin that the sensor is attached
to const int ledPin = 13; // pin that the LED is attached to
const int threshold = 400; // an arbitrary threshold level that's in the range of the analog input
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize serial
communications:
Serial.begin(9600);
}
void loop() {
// read the value of the potentiometer:
int analogValue = analogRead(analogPin);

// if the analog value is high enough, turn on the LED:


if (analogValue > threshold) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
// print the analog value:
Serial.println(analogValue);
delay(1); // delay in between reads for stability
}
Switch (case) Statement, used with sensor input
An if statement allows you to choose between two discrete options, TRUE or FALSE. When there are more
than two options, you can use multiple if statements, or you can use the switch statement. Switch allows you
to choose between several discrete options. This tutorial shows you how to use it to switch between four
desired states of a photo resistor: really dark, dim, medium, and bright.

This program first reads the photo resistor. Then it uses the map() function to map its output to one of four
values: 0, 1, 2, or 3. Finally, it uses the switch() statement to print one of four messages back to the computer
depending on which of the four values is returned.

Hardware Required

 Arduino or Genuino Board


 Photo resistor, or another analog sensor
 10k ohm resistors
 hook-up wires
 breadboard

Circuit
The photo resistor is connected to analog in pin 0 using a voltage divider circuit. A 10K ohm resistor makes
up the other side of the voltage divider, running from Analog in 0 to ground. The analogRead() function
returns a range of about 0 to 600 from this circuit in a reasonably lit indoor space.

2020- Government Polytechnic


Government Polytechnic
Institute
HUBLI

2020- Government Polytechnic


Government Polytechnic
Institute
HUBLI

Code
/*
Switch statement

Demonstrates the use of a switch statement. The switch statement allows you to choose from among a set
of discrete values of a variable. It's like a series of if statements.

To see this sketch in action, put the board and sensor in a well-lit room, open the Serial Monitor, and move
your hand gradually down over the sensor.

The circuit:
- photoresistor from analog in 0 to +5V
- 10K resistor from analog in 0 to ground
*/
// these constants won't change. They are the lowest and highest readings you
// get from your sensor:
const int sensorMin = 0; // sensor minimum, discovered through experiment
const int sensorMax = 600; // sensor maximum, discovered through
experiment

2020- Government Polytechnic


Government Polytechnic
Institute
HUBLI

2020- Government Polytechnic


Government Polytechnic
Institute
HUBLI
void setup() {
// initialize serial
communication:
Serial.begin(9600);
}
void loop() {
// read the sensor:
int sensorReading = analogRead(A0);
// map the sensor range to a range of four options:
int range = map(sensorReading, sensorMin, sensorMax, 0, 3);
// do something different depending on the range
value: switch (range) {
case 0: // your hand is on the
sensor Serial.println("dark");
break;
case 1: // your hand is close to the
sensor Serial.println("dim");
break;
case 2: // your hand is a few inches from the
sensor Serial.println("medium");
break;
case 3: // your hand is nowhere near the
sensor Serial.println("bright");
break;
}
delay(1); // delay in between reads for stability
}
Switch (case) Statement, used with serial input
An if statement allows you to choose between two discrete options, TRUE or FALSE. When there are more
than two options, you can use multiple if statements, or you can use the switch statement. Switch allows
you to choose between several discrete options.
This tutorial shows you how to use switch to turn on one of several different LEDs based on a byte of data
received serially. The sketch listens for serial input, and turns on a different LED for the characters a, b, c, d,
or e.
Hardware Required

 Arduino or Genuino Board


 5 LEDs
 5 220 ohm resistors
 hook-up wires
 breadboard

Circuit
Five LEDs are attached to digital pins 2, 3, 4, 5, and 6 in series through 220 ohm resistors.

To make this sketch work, your board must be connected to your computer. In the Arduino IDE open the
serial monitor and send the characters a, b, c, d, or e to lit up the corresponding LED, or anything else to
switch them off.

2020- Government Polytechnic


Government Polytechnic
Institute
HUBLI

2020- Government Polytechnic


Government Polytechnic
Institute
HUBLI

Code
/*
Switch statement with serial input

Demonstrates the use of a switch statement. The switch statement allows you to choose from among a
set of discrete values of a variable. It's like aseries of if statements.
To see this sketch in action, open the Serial monitor and send any character.The characters a, b, c, d, and e,
will turn on LEDs. Any other character will turn the LEDs off.

The circuit:
- five LEDs attached to digital pins 2 through 6 through 220 ohm resistors
*/
void setup() {
// initialize serial communication:
Serial.begin(9600);
// initialize the LED pins:

2020- Government Polytechnic


Government Polytechnic
Institute
HUBLI
for (int thisPin = 2; thisPin < 7; thisPin++) {
pinMode(thisPin, OUTPUT);
}
}

void loop() {
// read the sensor:
if (Serial.available() > 0) {
int inByte = Serial.read();
// do something different depending on the character received.
// The switch statement expects single number values for each case; in this
// example, though, you're using single quotes to tell the controller to get
// the ASCII value for the character. For example 'a' = 97, 'b' = 98,
// and so forth:
switch (inByte)
{ case 'a':
digitalWrite(2, HIGH);
break;
case 'b':
digitalWrite(3, HIGH);
break;
case 'c':
digitalWrite(4, HIGH);
break;
case 'd':
digitalWrite(5, HIGH);
break;
case 'e':
digitalWrite(6, HIGH);
break;
default:
// turn all the LEDs off:
for (int thisPin = 2; thisPin < 7; thisPin++) {
digitalWrite(thisPin, LOW);
} } }}
While Loop
 Sometimes you want everything in the program to stop while a given condition is true. You can
do this using a while loop. This example shows how to use a while loop to calibrate the value of
an analog sensor.
 In the main loop, the sketch below reads the value of a photoresistor on analog pin 0 and uses it to
fade an LED on pin 9. But while a button attached to digital pin 2 is pressed, the program runs a
method called calibrate() that looks for the highest and lowest values of the analog sensor. When
you release the button, the sketch continues with the main loop.
 This technique lets you update the maximum and minimum values for the photoresistor when the
lighting conditions change
Hardware Required
 Arduino or Genuino Board
 pushbutton or switch

2020- Government Polytechnic


Government Polytechnic
Institute
HUBLI

 photo resistor or another analog sensor


 2 10k ohm resistors
 breadboard

Circuit
Connect your analog sensor (e.g. potentiometer, light sensor) on analog input 2 with a 10K ohm resistor to
ground. Connect your button to digital pin, again with a 10K ohm resistor to ground. Connect your LED
to digital pin 9, with a 220 ohm resistor in series.

Code
/*
Conditionals - while statement. This example demonstrates the use of while() statements.
While the pushbutton is pressed, the sketch runs the calibration routine. The sensor readings during the
while loop define the minimum and maximum of expected values from the photo resistor.

2020- Government Polytechnic


Government Polytechnic
Institute
HUBLI
This is a variation on the calibrate
example. The circuit:
- photo resistor connected from +5V to analog in pin 0
- 10 kilohm resistor connected from ground to analog in pin 0
- LED connected from digital pin 9 to ground through 220 ohm resistor
- pushbutton attached from pin 2 to +5V
- 10 kilohm resistor attached from pin 2 to ground
*/
// These constants won't change:
const int sensorPin = A0; // pin that the sensor is attached
to const int ledPin = 9; // pin that the LED is attached to
const int indicatorLedPin = 13; // pin that the built-in LED is attached
to const int buttonPin = 2; // pin that the button is attached to
// These variables will change:
int sensorMin = 1023; // minimum sensor value
int sensorMax = 0; // maximum sensor value
int sensorValue = 0; // the sensor value
void setup() {
// set the LED pins as outputs and the switch pin as
input: pinMode(indicatorLedPin, OUTPUT);
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop() {
// while the button is pressed, take calibration
readings: while (digitalRead(buttonPin) == HIGH) {
calibrate();
}
// signal the end of the calibration
period digitalWrite(indicatorLedPin,
LOW);

// read the sensor:


sensorValue = analogRead(sensorPin);
// apply the calibration to the sensor reading
sensorValue = map(sensorValue, sensorMin, sensorMax, 0, 255);
// in case the sensor value is outside the range seen during calibration
sensorValue = constrain(sensorValue, 0, 255);
// fade the LED using the calibrated
value: analogWrite(ledPin, sensorValue);
}
void calibrate() {
// turn on the indicator LED to indicate that calibration is happening:
digitalWrite(indicatorLedPin, HIGH);
// read the sensor:
sensorValue = analogRead(sensorPin);
// record the maximum sensor
value if (sensorValue >
sensorMax) { sensorMax =
sensorValue;

2020- Government Polytechnic


Government Polytechnic
Institute
} HUBLI

2020- Government Polytechnic


Government Polytechnic
Institute
HUBLI

// record the minimum sensor


value if (sensorValue <
sensorMin) { sensorMin =
sensorValue;

Sensors

• A sensor acquires a physical quantity and converts it into a signal suitable for
processing (e.g. optical, electrical, mechanical)
• Nowadays common sensors convert measurement of physical phenomena into
an electrical signal
• Active element of a sensor is called a transducer.

Transducer
 A device which converts one form of energy to another
 When input is a physical quantity and output electrical → Sensor
 When input is electrical and output a physical quantity →Actuator
Sensor Actuator

PhysicalPrinciples:
Physical parameter Examples Electrical

• Amperes’s
ElectricalLaw
Output Input Physical
– A current carrying conductor in a magnetic field experiences a
force(e.g. galvanometer) Output

• Curie-Weiss Law
– There is a transition temperature at which ferromagnetic materialsexhibit
paramagnetic behavior

2020- Government Polytechnic


Government Polytechnic
Institute
HUBLI
• Faraday’s Law of Induction
– A coil resist a change in magnetic field by generating anopposing
voltage/current (e.g. transformer)

• Photoconductive Effect
– When light strikes certain semiconductor materials, the resistance of thematerial decreases
(e.g. photo resistor)
Need for Sensors
• Sensors are pervasive. They are embedded in our bodies, automobiles, airplanes,
cellular telephones, radios, chemical plants, industrial plants and countless other
applications.
• Without the use of sensors, there would be no automation !!

Motion Sensors
• Monitor location of various parts in a system
– absolute/relative position
– angular/relative displacement
– proximity
– acceleration
• Principle of operation
– Magnetic, resistive, capacitance, inductive, eddy current, etc.

LVDT Displacement Sensor Potentiometer

Optoisolator

2020- Government Polytechnic


Government Polytechnic
Institute
HUBLI

2020- Government Polytechnic


Government Polytechnic
Institute
HUBLI
Accelerometer–I
 Accelerometers are used to

measure acceleration along one or


more axis and are relatively
insensitive to orthogonal
directions

 Mathematical description
is beyond the scope of
this presentation.

Accelerometer Applications
• Automotive: monitor vehicle tilt, roll, skid, impact, vibration, etc., to deploy safety
devices (stability control, anti-lock breaking system, airbags, etc.) and to ensure
comfortable ride (active suspension)
• Aerospace: inertial navigation, smart munitions, unmanned vehicles
• Sports/Gaming: monitor athlete performance and injury, joystick, tilt
• Personal electronics: cell phones, digital devices
• Security: motion and vibration detection
• Industrial: machinery health monitoring
• Robotics: self-balancing
Light Sensor
– Light sensors are used in cameras, infrared detectors, and ambient lighting applications
– Sensor is composed of photoconductor such as a photo resistor, photodiode,
or phototransistor

2020- Government Polytechnic


Government Polytechnic
Institute
HUBLI
Magnetic Field Sensor

• Magnetic Field sensors are used for power steering, security, and current measurements
on transmission lines Hall voltage is proportional to magnetic field

Ultrasonic Sensor

• Ultrasonic sensors are used for position measurements


• Sound waves emitted are in the range of 2-13 MHz
• Sound Navigation And Ranging (SONAR)
• Radio Detection And Ranging (RADAR) – ELECTROMAGNETIC WAVES !!

Photogate

• Photogates are used in counting applications (e.g. finding period of period motion)

• Infrared transmitter and receiver at opposite ends of the sensor

• Time at which light is broken is recorded

2020- Government Polytechnic


Government Polytechnic
Institute
HUBLI

ACKNOWLEDGEMENT

I acknowledge my gratitude and thanks to all the well knowledge person for giving me
opportunity to get all the best facilities available at LCC Group Of Institutions. Success
of every training depends largely on the self and encouragement and guidance of many
others. I take this opportunity to express my gratitude to the people who has been
involved in the successful completion of this IN-PLANT TRAINING.

First of all, I would like to thank Mr Narasimha Anant Bargi , Mr Nagesh Baddi & the
Management of LCC Group Of Institutions for giving me the opportunity to do my 15
days in-plant training in their organization .I was with valuable advice and endless
supply of new ideas and support for this inplant training.

I would like to thank the principal Smt. Huded sir of “Government Polytechnic
Mundagod ” for giving us this opportunity.

Asmeen Doddamani

2020- Government Polytechnic


Government Polytechnic
Institute
HUBLI

2020- Government Polytechnic


Government Polytechnic
Institute
HUBLI

2020- Government Polytechnic

You might also like