Você está na página 1de 49

INDUSTRIAL TRAINING REPORT

ON

Industrial Training on IOT


(Based on Arduino)

SUBMITTED IN PARTIAL FULFILLMENT OF THE REQUIREMENTS


FOR THE AWARD OF THE DEGREE
OF

BACHELOR OF TECHNOLOGY
IN
ELECTRICAL AND ELECTRONICS
GURU GOBIND SINGH INDRAPRASTHA UNIVERSITY

Submitted by:

Sahil Kumar
(05215604916)
Dr. Akhilesh Das Gupta Institute of Technology &
Management
Shastri Park, Delhi 110053
August, 2019

i
CANDIDATE’S DECLARATION

It is hereby certified that the work which is being presented in the Industrial Training Report entitled "Industrial
Training on IOT" in partial fulfillment of the requirements for the award of the degree of Bachelor of
Technology and submitted in the Department of Electrical & Electronics Engineering of Dr. Akhilesh Das Gupta
Institute of Technology and Management, New Delhi (Affiliated to Guru Gobind Singh Indraprastha University,
Delhi) is an authentic record of our own industrial training carried out during the period from 1 st July 2019 to 1st
August 2019 at “NSIC Technical Services Centre, Okhla, New Delhi”.

SAHIL KUMAR
05215604916

This is to certify that the above statements made by the candidates are correct to the best of my knowledge. He is
permitted to appear in the External Industrial Training Examination. NSIC Technical Services Centre, Okhla,
New Delhi

Mr. Ajit Kumar Sharma External Examiner HOD,


EEE

ii
FOR CERTIFICATE

iii
ACKNOWLEDGEMENT

It is a pleasure to acknowledge many people who knowingly and unwittingly helped me, to
complete my Summer Training. First of all let us thank God for all the blessings, which carried us
through all these years.
I express my gratitude to Mr. PIYUSH BAGGA, at NSIC Technical Services Centre, Okhla
New Delhi, for providing this opportunity of getting one month summer training in Industrial
Training on IOT (Based on Arduino).
I would like to expresses my gratitude to my faculty members of Dr. Akhilesh Das Gupta
Institute of Technology & Management, Department of Electrical & Electronics Engineering
for providing academic inputs, guidance & encouragement for the training.

iv
ABSTRACT

The Internet of things (IoT) is the network of physical devices, vehicles and other items embedded
with software sensors, actuators, and connectivity which enables these things to connect. Simply
put, IoT is the concept of basically connecting any device with an on and off switch to the Internet
(and/or to each other). This includes everything from:-cellphones, coffee makers, washing
machines, headphones, lamps, wearable devices and almost anything else you can think of. This
also applies to components of machines, for example, a jet engine of an airplane.

Arduino interface boards provide the engineers, artists, designers, hobbyists and anyone who tinker
with technology with a low-cost, easy-to-use technology to create their creative, interactive
objects, useful projects etc. A whole new breed of projects can now be built that can be controlled
from a computer.

v
COMPANY PROFILE

National Small Industries Corporation (NSIC)


National Small Industries Corporation (NSIC), is an ISO 9001-2015 certified Government of India
Enterprise under Ministry of Micro, Small and Medium Enterprises (MSME).
NSIC has been working to promote, aid and foster the growth of micro, small and medium
enterprises in the country. NSIC operates through countrywide network of offices and Technical
Centers in the Country. In addition, NSIC has set up Training cum Incubation Centre managed by
professional manpower.
NSIC Technical Services Centre, Okhla New Delhi
Technology is the key to enhancing a company's competitive advantage in today's dynamic
information age. Small enterprises need to develop and implement a technology strategy in
addition to financial, marketing and operational strategies and adopt the one that helps integrate
their operations with their environment, customers and suppliers.
NSIC offers small enterprises the following support services through its Technical Services
Centers and Extension Centers:

1. Advise on application of new techniques.


2. Material testing facilities through accredited laboratories.
3. Product design including CAD.
4. Common facility support in machining, EDM, CNC, etc.
5. Energy and environment services at selected centers.
6. Classroom and practical training for skill up gradation.

About Company’s Mission & Vision

Mission: “To promote and support Micro, Small & Medium Enterprises (MSMEs) Sector” by
providing integrated support services encompassing Marketing, Technology, Finance and other
services.
Vision: “To be a premier Organization fostering the growth of Micro, Small and Medium
Enterprises (MSMEs) Sector”.

Various Services provided by the Company

Schemes of NSIC
NSIC facilitates Micro, Small and Medium Enterprises with a set of specially tailored scheme to
enhance their competitiveness. NSIC provides integrated support services under Marketing,
Technology, Finance and other Support service.
Marketing Support.
Consortia and Tender Marketing.

vi
Single point Registration for Government Purchase.
MSME Global Mart B2B Web Portal for MSMEs.
B2B Web portal is offering following benefits to the members of Infomediary Services.

 Interactive database of MSMEs


 Self-web development tool
 National Tenders on email
 Centralized mail system
 Popular Products Section
 Unlimited global Trade Leads
 Trust Seal of NSIC
 MSME Web Store
 Multiple Language Support
 Discussion Board
 Call Centre Support & Live Chat
 Other Value added Services
 Payment Gateway for membership subscription

Marketing Intelligence.
Exhibitions and Technology Fairs.
Buyer-Seller meets.
Credit Support.

vii
TABLE OF CONTENTS

TITLE PAGE NO.

REPORT TITLE i
CANDIDATE’S DECLARATION ii
CERTIFICATE iii
ACKNOWLEDEMENT iv
ABSTRACT v
COMPANY PROFILE vi-vii
TABLE OF CONTENTS viii-ix
LIST OF FIGURES x
LIST OF TABLES xi

CHAPTER 1 1-4
1.1 What is Embedded System? 1
1.2 Embedded Systems Hardware 1
1.3 Embedded Systems Software 1
1.4 What Is Arduino? 2
1.5 Types of Arduino Boards 2
1.6 Arduino Uno 3
1.7 Board Breakdown 3
1.8 Arduino Uno Technical Specifications 4

CHAPTER 2 5-8
2.1 WHAT IS AN LED? 5
2.2 HOW TO INTERFACE DEIVCE WITH ARDUINO UNO 5
2.3 7-SEGMENT DISPLAY 6
2.4 TPYES OF 7-SEGMENT DISPLAY 6
2.5 COMMON ANODE 7-SEGMENT DISPLAY 7
2.6 COMMON CATHODE 7-SEGMENT DISPLAY 7

CHAPTER 3 9-12
3.1 WHAT IS JOYSTICK 9
3.2 Joystick Module Pinout 9
3.3 WHAT IS LCD 10
3.4 16x2 LCD Display Modules 10
3.5 PIN DESCRIPTION OF 16X2 LCD 11

CHAPTER 4 13-17
4.1 WHAT IS SENSOR 13
4.2 Classification of Sensors 13
4.3 LDR (Light Dependent Resistor) 14
4.4 IR SENSOR 14

viii
4.5 IR SENSOR MODULE 14
4.6 ULTRASONIC SENSOR HC-SR04 15
4.7 How does it Work? 16

CHAPTER 5 18-20
5.1 MOTOR 18
5.2 THE BEGINNING OF MOTOR 18
5.3 TOWARDS PRACTICAL MOTOR 18
5.4 PROGRAM FOR INTERFACING DC MOTOR (PMDC)
WITH ARDUINO 18
5.5 LM293D 18
5.6 Working of L293D 19
5.7 L293D Logic Table. 19
5.8 SERVO MOTOR 20

CHAPTER 6 21-25
6.1 WHAT IS LINUX 21
6.2 Advantages of Linux 22
6.3 Linux Vs Windows Operating System 22
6.4 Linux Commands Raspberry Pi Users Need to Know 24

CONCLUSION 26-27
REFERNCES 28
APPENDICES 29-38
A.1 PROGRAM FOR BLINKING LED 29
A.2 PROGRAM FOR 2 LANE TRAFFIC LIGHT 29
A.3 PROGRAM FOR DISPLAYING ON 7-SEGMENT DISPLAY 30
A.4 PROGRAM FOR INTERFACING JOYSTICK WITH ARDUINO 33
A.5 PROGRAM FOR INTERFACING LCD TO ARDUINO 33
A.6 PROGRAM FOR DIPLAYING CUSTOM CHARACTERS ON LCD 34
A.7 PROGRAM TO GET ANALOG VALUE FROM LDR
IN ARDUINO SERIAL MONITOR 35
A.8 PROGRAM FOR CONTROLLING OBJECT USING IR MODULE
AND ARDUINO 35
A.9 PROGRAM TO GIVE DISTANCE on LCD USING HC-SR04 AND
ARDUINO UNO 36
A.10 PROGRAM TO INTERFACE DC MOTOR WITH ARDUINO 37
A.11 PROGRAM TO INTERFACE SERVO MOTOR TO ARDUINO 37

ix
LIST OF FIGURES

FIGURES PAGE NO.

Figure 1 Embedded Systems Design 1


Figure 2 Types of Arduino board 2
Figure 3 ARDUINO COMPONENTS 3
Figure 4 7-segment Display 6
Figure 5 7- Segment Display Configuration 7
Figure 6 JOYSTICK 9
Figure 7 JOYSTICK MODULE PINOUT 10
Figure 8 LCD MODULE 11
Figure 9 CONNECTION DIGRAM FOR LCD 12
Figure 10 LDR 14
Figure 11 IR SENSOR MODULE 14
Figure 12 UKTRASONIC SENSOR HC-SR04 16
Figure 13 HC-SR04 WORKING 16
Figure 14 WAVEFORM EMITS BY HC-SR04 17
Figure 15 HC-SR04 DISTANCE IN AIR 17
Figure 16 L239D PIN DIAGRAM 19
Figure 17 SERVO MOTOR 20

x
LIST OF TABLES

TABLES PAGE NO.

Table 1 COMMON ANODE 7-SEGMENT DISPLAY 7


Table 2 COMMON CATHODE 7-SEGMENT DISPLAY 8
Table 3 PIN DESCRIPTION OF 16x2 LCD 11-12
Table 4 LOGIC TABLE FOR LM239D 19

xi
CHAPTER 1: INTRODUCTION

1.1 What is Embedded System?


The electronic system which integrates the hardware circuitry with the software programming
techniques for providing project solutions is called as embedded systems. By using this embedded
system technology the complexity of the circuits can be reduced to a great extent which further
reduces the cost and size. Embedded system was primarily developed by Charles Stark for
reducing the size and weight of the project circuitry.

An embedded system is basically an


electronic system that can be
programmed or non-programmed to
operate, organize, and perform single
or multiple tasks based on the
application. In the real time embedded
systems, all the assembled units work
together based on the program or set of
rules or code embedded into the
microcontroller. But, by using
this microcontroller programming
techniques only a limited range of
problems can be solved.

Figure 1Embedded Systems Design

1.2 Embedded Systems Hardware


Every electronic system consists of hardware circuitry, similarly, embedded system consists of
hardware such as power supply kit, central processing unit, memory devices, timers, output
circuits, serial communication ports, and system application specific circuit components &
circuits.

1.3 Embedded Systems Software


An embedded system is integration of hardware and software, the software used in the embedded
system is set of instructions which is termed as a program. The microprocessors or
microcontrollers used in the hardware circuits of embedded systems are programmed to perform
specific tasks by following the set of instructions. These programs are primarily written using any
programming software like Proteus or Lab-view using any programming languages such as C or
C++ or embedded C. Then, the program is dumped into the microprocessors or microcontrollers
that are used in the embedded system circuits.

1
1.4 What Is Arduino?

Arduino is an open source programmable development board that can be integrated into a wide
variety of makerspace projects both simple and complex. This board contains a
microcontroller which is able to be programmed to sense and control objects in the physical
world. By responding to sensors and inputs, the Arduino is able to interact with a large array of
outputs such as LEDs, motors and displays. Because of its flexibility and low cost, Arduino has
become a very popular choice for makers and maker spaces looking to create interactive hardware
projects.
Arduino was introduced back in 2005 in Italy by Massimo Banzi as a way for non-engineers to
have access to a low cost, simple tool for creating hardware projects. Since the board is open-
source, it is released under a Creative Commons license which allows anyone to produce their own
board. If you search the web, you will find there are hundreds of Arduino compatible clones and
variations available but the only official boards have Arduino in its name.

1.5 Types of Arduino Boards

Arduino is a great platform for prototyping projects and inventions but can be confusing when
having to choose the right board. If you’re brand new to this, you might have always thought that
there was just one “Arduino” board and that’s it. In reality, there are many variations of the official
Arduino boards and then there are hundreds more from competitors who offer clones. One of the
best reasons to buy a clone is the fact they are generally less expensive than their official
counterpart. Adafruit and Sparkfun for example, sell variations of the Arduino boards which cost
less but still have the same quality of the originals.

1. Arduino UNO
2. Arduino Mega 2560
3. Arduino Duemilanove
4. Arduino Fio
5. LilyPad Arduino
6. Arduino Diecimila
7. Lilypad Arduino 03
8. Arduino NG Rev.C
9. Arduino Extreme
10. Arduino Mini 04

Figure 2Types of Arduino board

2
1.6 Arduino Uno

One of the most popular Arduino boards out there is the Arduino Uno. It is a microcontroller board
developed by Arduino.cc and based on Atmega328. Arduino Uno is a very valuable addition in
the electronics that consists of USB interface, 14 digital I/O pins, 6 analog pins, and Atmega328
microcontroller. It also supports serial communication using Tx and Rx pins. You should also have
a look at this UNO for beginners.

1.7 Board Breakdown

Here are the components that make up an Arduino board and what each of their functions are.

Figure 3 ARDUINO COMPONENTS

1. Reset Button – This will restart any code that is loaded to the Arduino board.
2. AREF – Stands for “Analog Reference” and is used to set an external reference voltage.
3. Ground Pin – There are a few ground pins on the Arduino and they all work the same.
4. Digital Input/Output – Pins 0-13 can be used for digital input or output.
5. PWM – The pins marked with the (~) symbol can simulate analog output.
6. USB Connection – Used for powering up your Arduino and uploading sketches.
7. TX/RX – Transmit and receive data indication LEDs.
8. ATmega Microcontroller – This is the brains and is where the programs are stored.
9. Power LED Indicator – This LED lights up anytime the board is plugged in a power
source.
10. Voltage Regulator – This controls the amount of voltage going into the Arduino board.
11. DC Power Barrel Jack – This is used for powering your Arduino with a power supply.
12. 3.3V Pin – This pin supplies 3.3 volts of power to your projects.
13. 5V Pin – This pin supplies 5 volts of power to your projects.
14. Ground Pins – There are a few ground pins on the Arduino and they all work the same.

3
15. Analog Pins – These pins can read the signal from an analog sensor and convert it to
digital.

1.8 Arduino Uno Technical Specifications

 Microcontroller: ATmega328.
 Operating Voltage: 5V.
 Input Voltage (recommended): 7-12V.
 Input Voltage (limits): 6-20V.
 Digital I/O Pins: 14 (of which 6 provide PWM output).
 Analog Input Pins: 6.
 DC Current per I/O Pin: 40 mA.
 DC Current for 3.3V Pin: 50 mA.
 Flash Memory: 32 KB of which 0.5 KB used by bootloader.
 SRAM: 2 KB (ATmega328).
 EEPROM: 1 KB (ATmega328).
 Clock Speed: 16 MHz.

4
CHAPTER 2: INTERFACING WITH LED AND 7 SEGMENT DISPLAY

2.1 WHAT IS AN LED?

A LED is a two-terminal semiconductor light source. This simple P-N junction diode emits light
when it gets activated and usually requires a small voltage for its operation. When voltage is
applied, the electrons will recombine with the holes and will release energy in the form of light.
The main semiconductor materials used to manufacture LEDs are:

 Indium gallium nitride (InGaN): blue, green and ultraviolet high-brightness LEDs.

 Aluminum gallium indium phosphide (AlGaInP): yellow, orange and red high-
brightness LEDs.

 Aluminum gallium arsenide (AlGaAs): red and infrared LEDs.

 Gallium phosphide (GaP): yellow and green LEDs.

2.2 HOW TO INTERFACE DEIVCE WITH ARDUINO UNO

1. Open the arduino IDE and write the program (in this case to blink an LED). After
writing the program you may save it with a file name of your choice (find File–>Save
on menu bar of IDE).
2. Selecting the board.You have to select the arduino board type in your IDE. I am using
an Arduino Uno board. To choose the board, find Tools on menu bar. Choose the option
“Board” – and select your correct arduino board. I have chosen arduino uno.

3. Select the right port. You can find the port number by accessing device manager on
Windows. See the section Port (COM & LPT) and look for an open port named
“Arduino Uno (COMxx) “. If you are using a different board, you will find a name
accordingly to select the right port, go to Tools–> Serial Port and select the port
number.

There are two steps involved in loading the program from your PC to arduino board via the arduino
IDE. First step is compiling and second step is called burning.

1. Compiling  – This is the process of converting the code you have just written in arduino
IDE to another form which is only understood by the microcontroller in your arduino

5
board. In the arduino IDE, compiling is called as “verify“. So hit the verify button in your
IDE (see the button with tick mark just below menu bar). When you hit the verify button,
the program you have written in arduino IDE will be compiled for any errors and then
converted to another form that microcontroller understands.

2. Burning – Embedded designers use the word “burning” to refer to uploading a program
to any micro controller. To do this, press the “upload” button (see the button with right
arrow mark). A click on the “upload” button will begin the process of burning the compiled
program to Avr micro controller on your arduino board. If you look on your arduino board,
you can see the 2 LED’s near Tx and Rx blinking. This is an indication of successful
communication between your PC and arduino board. If the program has been uploaded
successfully, you will see a message like “Done Uploading“. If the uploading process was
not successful, you will see an error message accordingly.

2.3 7-SEGMENT DISPLAY

The 7-segment display, also written as “seven segment display”, consists of seven LEDs (hence
its name) arranged in a rectangular fashion as shown. Each of the seven LEDs is called a segment
because when illuminated the segment forms part of a numerical digit (both Decimal and Hex)be
displayed. An additional 8th LED is sometimes used within the same package thus allowing the
indication of a decimal point, (DP) when two or more 7-segment displays are connected together
to display numbers greater than ten.

Figure 4 7-segment Display

2.4 TPYES OF 7-SEGMENT DISPLAY

There are two types of seven segment displays available in the market. According to the type of
application, these displays can be used. The two configurations of seven segment displays are
discussed below.

 Common Anode Display


 Common Cathode Display

6
Figure 5 7- Segment Display Configuration

2.5 COMMON ANODE 7-SEGMENT DISPLAY

In common anode type, all the anodes of 8 LED’s are connected to the common terminal and
cathodes are left free. Thus, in order to glow the LED, these cathodes have to be connected to the
logic ‘0’ and anode to the logic ‘1’.

Table 1 COMMON ANODE 7-SEGMENT DISPLAY

2.6 COMMON CATHODE 7-SEGMENT DISPLAY

As the name indicates cathode is the common pin for this type of seven segments and remaining 8
pins are left free. Here, logic low is applied to the common pin and logic high to the remaining
pins.

7
Table 2 COMMON CATHODE 7-SEGMENT DISPLAY

8
CHAPTER 3: INTERFACING WITH JOYSTICK AND LCD MODULES

3.1 WHAT IS JOYSTICK

Joystick is a lever that moves in all directions and controls the movement of a pointer or some
other display symbol. A joystick is similar to a mouse, except that with a mouse the cursor stops
moving as soon as you stop moving the mouse. With a joystick, the pointer continues moving in
the direction the joystick is pointing.

Figure 6 JOYSTICK

This is a joystick very similar to the ‘analog’ joysticks on PS2 (PlayStation 2) controllers. It is a
self-centering spring loaded joystick, meaning when you release the joystick it will center itself. It
also contains a comfortable cup-type knob/cap which gives the feel of a thumb-stick. The goal of
the joystick is to communicate motion in 2D (2-axis) to an Arduino. This is achieved by housing
two independent 10K potentiometers (one per axis). These potentiometers are used as dual
adjustable voltage dividers, providing 2-Axis analog input in a control stick form.

The potentiometers are the two blue boxes on the sides of the joystick. If you move the joystick
while watching the center shaft of each potentiometer, you’ll see that each of the potentiometers
pick up movement in only one direction.

3.2 Joystick Module Pinout

Let’s have a look at the pinout of 2-axis Thumb Joystick module.

 GND is the Ground Pin which we connect the GND pin on the Arduino.
 VCC supplies power for the module. You can connect it to 5V output from your Arduino.

9
 VRx gives readout of the joystick in the horizontal direction (X-coordinate) i.e. how far
left and right the joystick is pushed.
 VRy gives readout of the joystick in the vertical direction (Y-coordinate) i.e. how far up
and down the joystick is pushed.
 SW is the output from the pushbutton. It’s normally open, meaning the digital readout from
the SW pin will be HIGH. When the button is pushed, it will connect to GND, giving output
LOW.

Figure 7 JOYSTICK MODULE PINOUT

3.3 WHAT IS LCD

A liquid-crystal display (LCD) is a flat-panel display or other electronically modulated optical


device that uses the light-modulating properties of liquid crystals. Liquid crystals do not emit light
directly, instead using a backlight or reflector to produce images in color or monochrome.
A liquid crystal display utilizes two sheets of polarizing material with a liquid crystal solution
between them. When an electric current is passed through the liquid it causes the crystals to align
so that light cannot pass through them. Each crystal acts as a shutter, either allowing light to pass
through or blocking the light. LCDs alter the optical path of light when an electric field is placed
across the liquid crystal material.

3.4 16x2 LCD Display Modules

LCD (Liquid Crystal Display) screen is an electronic display module and find a wide range of
applications. A 16x2 LCD display is very basic module and is very commonly used in various
devices and circuits. These modules are preferred over seven segments and other multi segment
LEDs. The reasons being: LCDs are economical; easily programmable; have no limitation of
displaying special & even custom characters (unlike in seven segments), animations and so on.

10
A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In this LCD
each character is displayed in 5x8 pixel matrix. This LCD has two registers, namely, Command
and Data.
The command register stores the command instructions given to the LCD. A command is an
instruction given to LCD to do a predefined task like initializing it, clearing its screen, setting the
cursor position, controlling display etc. The data register stores the data to be displayed on the
LCD. The data is the ASCII value of the character to be displayed on the LCD. Click to learn more
about internal structure of a LCD.

Figure 8 LCD MODULE

3.5 PIN DESCRIPTION OF 16X2 LCD

1 Vss (Ground) Ground pin connected to system ground.


2 Vdd (+5 Volt) Powers the LCD with +5V (4.7V – 5.3V).
3 VE (Contrast V) Decides the contrast level of display. Grounded to get maximum
contrast.

4 Register Select Connected to Microcontroller to shit between command/data


register.
5 Read/Write Used to read or write data. Normally grounded to write data to
LCD.

6 Enable Connected to Microcontroller Pin and toggled between 1 and 0


for data acknowledgement.

7 Data Pin 0
8 Data Pin 1
9 Data Pin 2 Data pins 0 to 7 forms a 8-bit data line. They can be connected to
Microcontroller to send 8-bit data.
10 Data Pin 3
These LCD’s can also operate on 4-bit mode in such case Data
11 Data Pin 4
pin 4,5,6 and 7 will be left free.
12 Data Pin 5

11
13 Data Pin 6
14 Data Pin 7
15 LED Positive Backlight LED pin positive terminal.
16 LED Negative Backlight LED pin negative terminal.
Table 3 PIN DESCRIPTION OF 16x2 LCD

Figure 9 CONNECTION DIGRAM FOR LCD

12
CHAPTER 4: INTERFACING WITH SENSOR

4.1 WHAT IS SENSOR

A sensor is a device or a module that detect any changes in physical quantity (like pressure, force)
and convert it into electrical quantity.

4.2 Classification of Sensors

1. Active and Passive Sensors


2. Analog and Digital Sensors

Active Sensors
Active sensors are the type of sensors that produces output signal with help of external excitation
supply. The own physical properties of the sensor varies with respect to the applied external effect.
Therefore, it is also called as Self Generating Sensors.
Examples: LVDT and strain gauge.

Passive Sensors:
Passive sensors are the type of sensors that produces output signal without the help of external
excitation supply. They do not need any extra stimulus or voltage.
Example: Thermocouple, which generates a voltage value corresponding to the heat, applied. It
does not require any external power supply.

Analog Sensors
The sensor that produces continuous signal with respect to time with analog output is called as
Analog sensors. The analog output generated is proportional to the measured or the input given to
the system.
Examples: accelerometers, speed sensors, pressure sensors, light sensors, temperature sensors.

Digital Sensors
When data is converted and transmitted digitally, it is called as Digital sensors. Digital sensors are
the one, which produces discrete output signals. Discrete signals will be non-continuous with time
and it can be represented in “bits” for serial transmission and in “bytes” for parallel transmission.
The measuring quantity will be represented in digital format. Digital output can be in form of
Logic 1 or logic 0 (ON or OFF).

13
Examples: Digital Accelerometer, light sensors.

4.3 LDR (Light Dependent Resistor)

An LDR is a component that has a (variable) resistance that changes with the light intensity that
falls upon it. This allows them to be used in light sensing circuits.

Figure 10 LDR

4.4 IR SENSOR

IR sensor is a simple electronic device which emits and detects IR radiation in order to find out
certain objects/obstacles in its range. Some of its features are heat and motion sensing.IR sensors
use infrared radiation of wavelength between 0.75 to 1000µm which falls between visible and
microwave regions of electromagnetic spectrum.

4.5 IR SENSOR MODULE

Figure 11 IR SENSOR MODULE

14
The IR sensor module consists mainly of the IR Transmitter and Receiver, Opamp, Variable
Resistor (Trimmer pot), output LED in brief.

IR LED Transmitter
IR LED emits light, in the range of Infrared frequency. IR LEDs have light emitting angle of
approx. 20-60 degree and range of approx. few centimeters to several feets, it depends upon the
type of IR transmitter and the manufacturer.

Photodiode Receiver
Photodiode acts as the IR receiver as its conducts when light falls on it. Photodiode is a
semiconductor which has a P-N junction, operated in Reverse Bias, means it start conducting the
current in reverse direction when Light falls on it, and the amount of current flow is proportional
to the amount of Light. This property makes it useful for IR detection.
LM358 Opamp
LM358 is an Operational Amplifier (Op-Amp) is used as voltage comparator in the IR sensor. The
comparator will compare the threshold voltage set using the preset (pin2) and the photodiode’s
series resistor voltage (pin3).
Photodiode’s series resistor voltage drop > Threshold voltage = Opamp output is High
Photodiode’s series resistor voltage drop < Threshold voltage = Opamp output is Low
When Opamp's output is high the LED at the Opamp output terminal turns ON (Indicating the
detection of Object).

Variable Resistor
The variable resistor used here is a preset. It is used to calibrate the distance range at which object
should be detected.

4.6 ULTRASONIC SENSOR HC-SR04

The HC-SR04 ultrasonic sensor uses sonar to determine distance to an object like bats do. It offers
excellent non-contact range detection with high accuracy and stable readings in an easy-to-use
package. It comes complete with ultrasonic transmitter and receiver modules.

Features

Here’s a list of some of the HC-SR04 ultrasonic sensor features and specs:

 Power Supply :+5V DC


 Quiescent Current : <2mA
 Working Current: 15mA

15
 Effectual Angle: <15°
 Ranging Distance : 2cm – 400 cm/1″ – 13ft
 Resolution : 0.3 cm
 Measuring Angle: 30 degree
 Trigger Input Pulse width: 10uS
 Dimension: 45mm x 20mm x 15mm

Figure 12 ULTRASONIC SENSOR HC-SR04

4.7 How does it Work?

Figure 13 HC-SR04 WORKING

The ultrasonic sensor uses sonar to determine the distance to an object. Here’s what happens:

1. The transmitter (trig pin) sends a signal: a high-frequency sound.


2. When the signal finds an object, it is reflected.

16
3. The transmitter (echo pin) receives it.
The time between the transmission and reception of the signal allows us to calculate the distance
to an object. This is possible because we know the sound’s velocity in the air.
The HC-SR04 Ultrasonic Module has 4 pins, Ground, VCC, Trig and Echo. The Ground and the
VCC pins of the module needs to be connected to the Ground and the 5 volts pins on the Arduino
Board respectively and the trig and echo pins to any Digital I/O pin on the Arduino Board.
In order to generate the ultrasound you need to set the Trig on a High State for 10 µs. That will
send out an 8 cycle sonic burst which will travel at the speed sound and it will be received in the
Echo pin. The Echo pin will output the time in microseconds the sound wave traveled.

Figure 14 WAVEFORM EMITS BY HC-SR04

For example, if the object is 10 cm away from the sensor, and the speed of the sound is 340 m/s or
0.034 cm/µs the sound wave will need to travel about 294 u seconds. But what you will get from
the Echo pin will be double that number because the sound wave needs to travel forward and
bounce backward. So in order to get the distance in cm we need to multiply the received travel
time value from the echo pin by 0.034 and divide it by 2.

Figure 15 HC-SR04 DISTANCE IN AIR

17
CHAPTER 5: INTERFACING WITH MOTOR

5.1 MOTOR

A motor is a machine that converts electrical energy to mechanical energy.

5.2 THE BEGINNING OF MOTOR

In 1831, a British physicist, Michael Faraday, discovered the law of electromagnetic induction that
electric current flows when you move magnets in air core coil. The law of electromagnetic
induction proved that the electrical energy and the mechanical energy are mutually convertible. It
is said that this is the catalyst of invention of motors.

5.3 TOWARDS PRACTICAL MOTOR

Since the discovery of electromagnetic induction by Faraday, people had invented a number of
motors. In 1834, Thomas Davenport invented a practical DC motor. After that, a Yugoslavian
electrical engineer, later became an American, Nikola Tesla, came up with an idea to drive motors
with alternating current. In 1882, the idea of the principle of rotating magnetic field suddenly hit
his head when he was walking in the park. In 1887, he completed a practical two-phase AC motor
(induction motor) using rotating magnetic field. Since then AC technologies such as transformer,
three-phase-three-wire system have developed as well as power network. The more available the
electricity became, the wider the usage of motors expanded.

5.4 PROGRAM FOR INTERFACING DC MOTOR (PMDC) WITH ARDUINO

A DC motor is any of a class of rotary electrical machines that converts direct current electrical
energy into mechanical energy.
For interfacing dc motor with arduino we requires a motor driver LM293D. From microcontroller
we cannot connect a motor directly because microcontroller cannot give sufficient current to
drive the DC motors. Motor driver is a current enhancing device, it can also be act as Switching
Device. Thus we insert motor driver in between motor and microcontroller. Motor driver take
the input signals from microcontroller and generate corresponding output for motor.

5.5 LM293D

This is a motor driver IC that can drive two motor simultaneously. L293D IC is a dual H-bridge
motor driver IC. One H-bridge is capable to drive a dc motor in bidirectional. L293D IC is a current
enhancing IC as the output from the sensor is not able to drive motors itself so L293D is used for
this purpose. L293D is a 16 pin IC having two enables pins which should always be remain high
to enable both the H-bridges. L293B is another IC of L293 series.

18
Figure 16 LM239D PIN DIAGRAM

5.6 Working of L293D

There are 4 input pins for l293d, pin 2, 7 on the left and pin 15, 10 on the right as shown on the
pin diagram. Left input pins will regulate the rotation of motor connected across left side and right
input for motor on the right hand side. The motors are rotated on the basis of the inputs provided
across the input pins as LOGIC 0 or LOGIC 1.
In simple you need to provide Logic 0 or 1 across the input pins for rotating the motor.

5.7 L293D Logic Table.

Let’s consider a Motor connected on left side output pins (pin 3, 6). For rotating the motor in
clockwise direction the input pins has to be provided with Logic 1 and Logic 0.

PIN NO. 2/15 INPUT PIN NO. 7/10 INPUT OUTPUT


LOGIC 0 LOGIC 0 Idle [No rotation] [Hi-Impedance state]
LOGIC 0 LOGIC 1 Anticlockwise Direction
LOGIC 1 LOGIC 0 Clockwise Direction
LOGIC 1 LOGIC 1 Idle [No rotation]
Table 4 LOGIC TABLE FOR LM239D

In a very similar way the motor can also operate across input pin 15, 10 for motor on the right hand
side.

19
5.8 SERVO MOTOR

A servo motor is an electric device used for precise control of angular rotation. It is used in
applications that demand precise control over motion, like in case of control of a robotic arm.
Servo motor consists of DC motor with error sensing negative feedback mechanism. This allows
precise control over angular velocity and position of motor. In some cases, AC motors are used.
The rotation angle of the servo motor is controlled by applying a PWM signal to it. By varying the
width of the PWM signal, we can change the rotation angle and direction of the motor. It is a closed
loop system where it uses negative feedback to control motion and final position of the shaft. It is
not used for continuous rotation like conventional AC/DC motors. It has rotation angle that varies
from 0° to 180°.

As shown in figure Servo motor has three pins for its operation as,

 +VCC (RED)

- Connect +VCC supply to this pin. For SG90 Micro Servo it is 4.8 V (~5V).

 Ground (BROWN)

- Connect Ground to this pin.

 Control Signal (ORANGE)

- Connect PWM of 20ms (50 Hz) period to this pin.

Figure 17 SERVO MOTOR

20
CHAPTER 6: LINUX OPERATING SYSTEM

6.1 WHAT IS LINUX

Linux is a free and open source operating system based on UNIX standards. It provides
programming interface as well as user interface compatible with UNIX based systems and
provides large variety applications. A Linux system also contains many separately developed
elements, resulting in UNIX system which is fully compatible and free from proprietary code.
The Linux operating system comprises several different pieces:

1. Bootloader – The software that manages the boot process of your computer. For most
users, this will simply be a splash screen that pops up and eventually goes away to boot
into the operating system.
2. Kernel – This is the one piece of the whole that is actually called? Linux? The kernel
is the core of the system and manages the CPU, memory, and peripheral devices. The
kernel is the lowest level of the OS.
3. Init system – This is a sub-system that bootstraps the user space and is charged with
controlling daemons. One of the most widely used init systems is systemd? which also
happens to be one of the most controversial. It is the in it system that manages the boot
process, once the initial booting is handed over from the bootloader (i.e., GRUB or
GRand Unified Bootloader).
4. Daemons – These are background services (printing, sound, scheduling, etc.) that either
start up during boot or after you log into the desktop.
5. Graphical server – This is the sub-system that displays the graphics on your monitor.
It is commonly referred to as the X server or just X.
6. Desktop environment – This is the piece that the users actually interact with. There
are many desktop environments to choose from (GNOME, Cinnamon, Mate, Pantheon,
Enlightenment, KDE, Xfce, etc.). Each desktop environment includes built-in
applications (such as file managers, configuration tools, web browsers, and games).
7. Applications – Desktop environments do not offer the full array of apps. Just like
Windows and macOS, Linux offers thousands upon thousands of high-quality software
titles that can be easily found and installed. Most modern Linux distributions (more on
this below) include App Store-like tools that centralize and simplify application
installation. For example, Ubuntu Linux has the Ubuntu Software Center (a rebrand of
GNOME Software? Figure 1) which allows you to quickly search among the thousands
of apps and install them from one centralized location.

21
6.2 Advantages of Linux

1. Open source
2. Low cost
3. Stability
4. Performance
5. Flexibility
6. Compatibility
7. Security
8. Networking
9. Multitasking
10. Fast and easy installation
11. Better use of hard disk

6.3 Linux Vs Windows Operating System

BASIS FOR
LINUX WINDOWS
COMPARISON

Cost Free of cost Expensive

Open source Yes No

Customizable Yes No

22
BASIS FOR
LINUX WINDOWS
COMPARISON

Security More secure Vulnerable to viruses and

malware attacks.

Booting Either primary or logical Only primary partition.

partition.

Separation of the Forward slash Back slash

directories using

File names Case sensitive Case insensitive

File system EXT2, EXT3, EXT4, Reisers FS, FAT, FAT32, NTFS and ReFS

XFS and JFS

Type of kernel used Monolithic kernel Microkernel

Efficiency Effective running efficiency Lower than Linux

23
6.4 Linux Commands Raspberry Pi Users Need to Know

ls
The ls command lists the content of the current directory (or one that is specified). It can be used
with the -l flag to display additional information (permissions, owner, group, size, date and
timestamp of last edit) about each file and directory in a list format. The -a flag allows you to view
files beginning with(i.e. dotfiles).

cd
Using cd changes the current directory to the one specified. You can use relative (i.e. cd
directoryA) or absolute (i.e. cd /home/pi/directoryA) paths.

pwd
The pwd command displays the name of the present working directory: on a Raspberry Pi, entering
pwd will output something like /home/pi.

mkdir
You can use mkdir to create a new directory, e.g. mkdir newDir would create the directory newDir
in the present working directory.

rmdir
To remove empty directories, use rmdir. So, for example, rmdir oldDir will remove the directory
oldDir only if it is empty.

rm
The command rmremoves the specified file (or recursively from a directory when used with -r).
Be careful with this command: files deleted in this way are mostly gone for good!

cp
Using cp makes a copy of a file and places it at the specified location (this is similar to copying
and pasting). For example, cp ~/fileA /home/otherUser/ would copy the file fileA from your home
directory to that of the user otherUser (assuming you have permission to copy it there). This
command can either take FILE FILE (cp fileA fileB), FILE DIR (cp fileA /directoryB/) or -r DIR
DIR (which recursively copies the contents of directories) as arguments.

mv
The mv command moves a file and places it at the specified location (so where cp performs a
'copy-paste', mv performs a 'cut-paste'). The usage is similar to cp. So mv ~/fileA
/home/otherUser/ would move the file fileA from your home directory to that of the user otherUser.
This command can either take FILE FILE (mv fileA fileB), FILE DIR (mv fileA /directoryB/) or
DIR DIR (mv /directoryB /directoryC) as arguments. This command is also useful as a method to
rename files and directories after they've been created.

24
touch
The command touch sets the last modified time-stamp of the specified file(s) or creates it if it does
not already exist.

cat
You can use cat to list the contents of file(s), e.g. cat thisFile will display the contents of thisFile.
Can be used to list the contents of multiple files, i.e. cat *.txt will list the contents of all .txt files
in the current directory.

sudo
The sudo command enables you to run a command as a super user, or another user. Use sudo -s
for a super user shell. For more details see Root user / su.

25
CONCLUSION

Internet of Things is a network constituted by uniquely identifiable commodity objects or devices


equipped with some sensing system. Internet of Things paradigm enables the objects, also called
things, for sensing, which subsequently inter-operate and communicates with other objects for data
exchange through an existing physical network infrastructure. Therefore, Internet of Things
promotes a seamless amalgamation between the smart devices, scatter around us, and the physical
world to ensure full automation that eventually ameliorates human life. Some of the examples of
Internet of Things-enabled commodity devices or things include heart monitoring implants,
automobiles with embedded sensors, firefighter’ devices, smart thermostat systems, and Wi-Fi
enabled washer/dryers. As the arena of Internet of Things is expanding, the number of Internet of
Things-enabled applications is also rapidly growing, which results in massive growth of smart
devices in multiple order comparatively. This swift increase in the number of sensing things is
responsible for generating and storage of a plethora amount of diversified data at much faster
rate.

The Internet of Things sense and collect the data from the highly sparse geographical
environments. The data is exchanged with remotely stationed peer devices for numerous quick and
efficient operations such agglomeration; this is where the traditional data management
mechanisms succumb and opportunity for some new powerful technologies arises. As a result,
today, the cloud computing technology has emerged as one such innovation that have been
invented to efficiently tackle the growing Internet of Things issues. Internet of Things paradigm is
increasingly encouraging the ubiquitous connectivity of the intelligent objects within internal or
external world. The continuous rapid growth of large number of Internet of Things- enabled objects
and storage technology have resulted into the massive amount of heterogeneous digital footprints
and sizeable traces. A vast amount of data is being generated by various sensing sources every
day. It is observed that the primary sources of Internet of Things are sensor-enabled devices, unlike
the traditional Big Data, where social media is the major contributor in data collection as compared
to the sensing systems. Therefore, Internet of Things can be seen as a subset of traditional Big
Data. The actual pattern and nature of such data is indistinct, but is certainly large, complex,

26
heterogeneous, structure and unstructured. Literature demonstrates some important attributes of
Internet of Things such as volume, variety, and velocity and some core constituents of Internet of
Things like sensor-embedded devices, intelligence for quick decision making, and connectivity for
data sharing. Apparently, to obtain constructive insights from Internet of Things, gigantic efforts
are required for Internet of Things modeling in contrast to that of traditional data. Also, the rapid
growth of sensing devices under Internet of Things purview is generating such a large scale
complex and heterogeneous data that the available computing capacity of the existing systems
unable to successfully match up the data challenges and today, this has emerged as one of the core
issues for the data science community. The storage capacity and also the processing power of the
existing data computing systems are failed in handling the data stress. As Internet of Things and
its applications are majorly impacting the human life, the scientific communities contemplate a
broader outreach from the processing and sharing of Internet of Things across the variety of the
several commodity devices around us. Consequently, the development of new capable
technologies is encouraged to cater the current data processing need.

27
REFERENCES

[1] John Nussey “Arduino For Dummies” John Wiley & Sons, Ltd, Chichester, West Sussex, England 2013.

[2] Simon Monk “30 Arduino Projects for the Evil Genius, Second Edition, 2nd Edition” McGraw-Hill Education
TAB June 2013.

[3] Richard Blum “Arduino Programming in 24 Hours, Sams Teach Yourself” Sams Publishing August 31st 2014.

[4] Massimo Banzi and Michael Shiloh “Getting Started with Arduino, 3rd Edition” Make Community, LLC,
December 2014

28
APPENDICES

A.1 PROGRAM FOR BLINKING LED

int LED = 13; //led is on pin 13


// the setup function runs once when you press reset or power the board
void setup()
{
// initialize digital pin LED as an output.
pinMode(LED, OUTPUT);
}

// the loop function runs over and over again forever


void loop()
{
digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

A.2 PROGRAM FOR 2 LANE TRAFFIC LIGHT

void setup()
{
pinMode(0,OUTPUT); //green 1:
pinMode(1,OUTPUT); //yellow 1:
pinMode(2,OUTPUT); //red 1:
pinMode(3,OUTPUT); //red 2:
pinMode(4,OUTPUT); //yellow 2:
pinMode(5,OUTPUT); //green 2:
}
void loop() {
digitalWrite(0,HIGH);
digitalWrite(3,HIGH);
digitalWrite(1,LOW);
digitalWrite(2,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
delay(10000);
digitalWrite(1,HIGH);
digitalWrite(5,HIGH);
digitalWrite(0,LOW);

29
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
delay(3000);
digitalWrite(2,HIGH);
digitalWrite(5,HIGH);
digitalWrite(0,LOW);
digitalWrite(1,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
delay(7000);
digitalWrite(2,HIGH);
digitalWrite(4,HIGH);
digitalWrite(0,LOW);
digitalWrite(1,LOW);
digitalWrite(3,LOW);
digitalWrite(5,LOW);
delay(3000);
}

A.3 PROGRAM FOR DISPLAYING ON 7-SEGMENT DISPLAY

For displaying sahil7211 :-


int a=1;
int b=2;
int c=3;
int d=4;
int e=5;
int f=6;
int g=7;

void setup()
{
pinMode(a,OUTPUT);
pinMode(b,OUTPUT);
pinMode(c,OUTPUT);
pinMode(d,OUTPUT);
pinMode(e,OUTPUT);
pinMode(f,OUTPUT);
pinMode(g,OUTPUT);
}

void loop()
{
digitalWrite(b,LOW); // S IS DISPLAYING

30
digitalWrite(e,LOW);
digitalWrite(a,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
delay(1000);

digitalWrite(d,LOW); // A IS DISPLAYING
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
delay(1000);

digitalWrite(a,LOW); // H IS DISPLAYING
digitalWrite(d,LOW);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
delay(1000);

digitalWrite(a,LOW); // I IS DISPLAYING
digitalWrite(b,LOW);
digitalWrite(c,LOW);
digitalWrite(d,LOW);
digitalWrite(g,LOW);
digitalWrite(f,HIGH);
digitalWrite(e,HIGH);
delay(1000);

digitalWrite(a,LOW); // L IS DISPLAYING
digitalWrite(b,LOW);
digitalWrite(c,LOW);
digitalWrite(g,LOW);
digitalWrite(d,HIGH);
digitalWrite(f,HIGH);
digitalWrite(e,HIGH);
delay(1000);

digitalWrite(d,LOW); // 7 IS DISPLAYING
digitalWrite(e,LOW);

31
digitalWrite(f,LOW);
digitalWrite(g,LOW);
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
delay(1000);

digitalWrite(f,LOW); // 2 IS DISPLAYING
digitalWrite(c,LOW);
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(g,HIGH);
delay(1000);

digitalWrite(a,LOW); // 1 IS DISPLAYING
digitalWrite(d,LOW);
digitalWrite(e,LOW);
digitalWrite(f,LOW);
digitalWrite(g,LOW);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
delay(1000);

digitalWrite(a,LOW); // NOTHING IS DISPLAYED


digitalWrite(d,LOW);
digitalWrite(e,LOW);
digitalWrite(f,LOW);
digitalWrite(g,LOW);
digitalWrite(b,LOW);
digitalWrite(c,LOW);
delay(500);

digitalWrite(a,LOW); // 1 IS DISPLAYING
digitalWrite(d,LOW);
digitalWrite(e,LOW);
digitalWrite(f,LOW);
digitalWrite(g,LOW);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
delay(1000);
}

32
A.4 PROGRAM FOR INTERFACING JOYSTICK WITH ARDUINO

void setup ()
{
pinMode(A2,INPUT);
pinMode(A3,INPUT);
pinMode(A4,INPUT);
pinMode(A5,INPUT);
Serial.begin(9600)
}

void loop()
{
Serial.print("J1X=");
Serial.print(analogRead(A2));
Serial.print("\t");
delay(1000);
Serial.print("J1Y=");
Serial.print(analogRead(A3));
Serial.print("\t");
delay(1000);
Serial.print("J2X=");
Serial.print(analogRead(A4));
Serial.print("\t");
delay(1000);
Serial.print("J2X=");
Serial.print(analogRead(A5));
Serial.print("\t");
delay(1000);
}

A.5 PROGRAM FOR INTERFACING LCD TO ARDUINO

#include <LiquidCrystal.h> // includes the LiquidCrystal Library


LiquidCrystal lcd(1,2,4,5,6,7); //REGISTER SELECT PIN,ENABLE PIN,D4 PIN,D5 PIN, D6
PIN, D7 PIN
void setup()
{
lcd.begin(16,2); // set up the LCD's number of columns and rows
}
void loop()
{
lcd.print("WELCOME TO"); // print on lcd
delay(2000); // dealy for 2s
lcd.setCursor(2,1); // stes the location at which subsequent text written to lcd will display

33
lcd.print("ADGITM");
delay(2000);
lcd.clear(); // clears the lcd
lcd.blink(); // displays the blinking lcd cursor
delay(2000);
lcd.setCursor(7,1);
delay(2000);
lcd.noBlink(); // turn off blinking lcd cursor
lcd.cursor();
delay(2000);
lcd.noCursor(); // hides the cursor
lcd.clear();
}

A.6 PROGRAM FOR DIPLAYING CUSTOM CHARACTERS ON LCD

#include<LiquidCrystal.h>
byte slash[8]={ // Array of bytes
B11111, // B stands for binay formatter and the 5 numbers are the pixels
B11111,
B10101,
B11111,
B10101,
B11011,
B11111,
B11111,
};
LiquidCrystal lcd(1,2,4,5,6,7);
void setup()
{
lcd.begin(16,2);
lcd.createChar(10,slash); // create a custom character for use on the lcd.
}
void loop()
{
for(int i=0;i<=15;i++)
{
lcd.setCursor(i,0);
lcd.write(10);
delay(1000);
lcd.clear();
}
}

34
A.7 PROGRAM TO GET ANALOG VALUE FROM LDR IN ARDUINO SERIAL
MONITOR

void setup()
{
pinMode(13,OUTPUT);
Serial.begin(9600);
}

void loop()
{
int Sensorvalue=analogRead(A0);
if(Sensorvalue>=100 && Sensorvalue<=200)
{
digitalWrite(13,HIGH);
}
else
{
digitalWrite(13,LOW);
}
Serial.println(Sensorvalue);
}

A.8 PROGRAM FOR CONTROLLING OBJECT USING IR MODULE AND ARDUINO

void setup()
{
lcd.begin(16,2);
pinMode(7,INPUT);
Serial.begin(9600);
pinMode(13,OUTPUT);
}

void loop()
{
Serial.print("IRSensorip");
Serial.println(digitalRead(7));

if(digitalRead(7)==0)
{
lcd.print("DOOR OPEN");
digitalWrite(13,HIGH);
delay(1000);
lcd.clear();
}

35
else
{
lcd.print("DOOR CLOSE");
digitalWrite(13,LOW);
delay(1000);
lcd.clear();
}
}

A.9 PROGRAM TO GIVE DISTANCE on LCD USING HC-SR04 AND ARDUINO UNO

#include <LiquidCrystal.h> // includes the LiquidCrystal Library


LiquidCrystal lcd(1, 2, 4, 5, 6, 7); // Creates an LCD object. Parameters: (rs, enable, d4, d5, d6,
d7)
const int trigPin = 9;
const int echoPin = 10;
long duration;
int distanceCm, distanceInch;
void setup()
{
lcd.begin(16,2); // Initializes the interface to the LCD screen, and specifies the dimensions (width
and height) of the display
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}

void loop()
{
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distanceCm= duration*0.034/2;
distanceInch = duration*0.0133/2;
lcd.setCursor(0,0); // Sets the location at which subsequent text written to the LCD will be
displayed
lcd.print("Distance: "); // Prints string "Distance" on the LCD
lcd.print(distanceCm); // Prints the distance value from the sensor
lcd.print(" cm");
delay(10);
lcd.setCursor(0,1);
lcd.print("Distance: ");
lcd.print(distanceInch);
lcd.print(" inch");

36
delay(10);
}

A.10 PROGRAM TO INTERFACE DC MOTOR WITH ARDUINO

//Motor A
const int inputPin1 = 10; // Pin 15 of L293D IC
const int inputPin2 = 11; // Pin 10 of L293D IC
//Motor B
const int inputPin3 = 9; // Pin 7 of L293D IC
const int inputPin4 = 8; // Pin 2 of L293D IC

void setup()
{
pinMode(inputPin1, OUTPUT);
pinMode(inputPin2, OUTPUT);
pinMode(inputPin3, OUTPUT);
pinMode(inputPin4, OUTPUT);
}

void loop()
{
digitalWrite(inputPin1, HIGH);
digitalWrite(inputPin2, LOW);
digitalWrite(inputPin3, HIGH);
digitalWrite(inputPin4, LOW);
}

A.11 PROGRAM TO INTERFACE SERVO MOTOR TO ARDUINO

#include <Servo.h>

#include<Servo.h>
Servo myservo;
int pos = 40;

void setup() {
myservo.attach(3);
}

void loop()
{
for (pos=0; pos<=180; pos +=1)

37
{
myservo.write(pos);
delay(50);
}
for (pos = 180; pos>=0; pos-=1)
{
myservo.write (pos);
delay(50);
}
}

38

Você também pode gostar