0% found this document useful (0 votes)
19 views123 pages

Precision Engineering Lab Manuals

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

Precision Engineering Lab Manuals

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

Precision Engineering Lab

Lab Manuals

Submitted By
Name: Abuhoraira Khalil
Reg No: MEEN201101003

Submitted To
Engr Syed Saad Farooq

DEPARTMENT OF MECHANICAL ENGINEERING


KHWAJA FAREED UNIVERSITY OF ENGINEERING &
INFORMATION TECHNOLOGY, RAHIM YAR KHAN (64200)
PAKISTAN
List of Experiment/tasks in precision Engineering and Metrology

Task 1:

Using 3 LED’s (red, yellow and green) build a traffic light that
Illuminates the green LED for 5 seconds
Illuminates the yellow LED for 2 seconds
Illuminates the red LED for 5 seconds
repeats the sequence
Lab #1 &
2 Note that after each illumination period the LED is turned off!
Task 2:

Modify Task 1 to have an advanced green (blinking green LED) for 3 seconds before illuminating the
green LED for 5 seconds.

Task 3:
Lab #3
Create a dimmer switch by adding a potentiometer to control the brightness of LED, more over
attach a push button on the bread board for controlling the LED (on or off)

Task 4:
Lab #4
Make a circuit composed of infra-red sensor or ultra-sonic sensor for the presence of any intruder
in the area of concern. (use of proximity)

Task 5:
Lab #5
Introduce a new sensor and compile the code that detects moisture levels of a plant and set any
LED or sound attached with it for indication that plant needs watering

Task 6:
Lab #6
Introduce the keypad to your Arduino by building a keypad entry system. (locking or unlocking any
case by password)

Task 7:
Lab #7
Make Arduino based controlling of power through light sensor (will be used in solar tracking)

Task 8:
Lab#8
Make Arduino based digital thermometer and show its value on LCD display

Task 9 & 10:

Lab # 9 & Design the Arduino based code to control the speed of motor using potentiometer and also a code
10 for direction control (H bridge circuiting )
Task 11:
Lab #11
& 12 Design basic calculator using switches and LEDs (use only addition, subtraction , multiplication and
division)

Task 13:
Lab #13
& 14 Design home energy saving system with autonomous techniques using sensors. (Autonomous
switching of lights). Design a smart home on hard board.

Task 15 & 16:


Lab #15
& 16 Design control system using Arduino with the help of sensors for autonomous water flow and tank
filling
Experiment 01
Task:
Using 3 LED’s (red, yellow and green) build a traffic light that

• Illuminates the green LED for 5 seconds


• Illuminates the yellow LED for 2 seconds
• Illuminates the red LED for 5 seconds

repeats the sequence.

Parts Required:
The parts required for this task are

➢ Arduino Uno
➢ Breadboard
➢ Jumper Wires
➢ LED (Red, Yellow, Green)
➢ Resistor

1) Arduino Uno:
The Arduino Uno is an open-source microcontroller board based on the Microchip
ATmega328P microcontroller and developed by Arduino.cc and initially released in 2010. The
board is equipped with sets of digital and analog input/output (I/O) pins that may be interfaced to
various expansion boards (shields) and other circuits.

The board has 14 digital I/O pins (six capable of PWM output), 6 analog I/O pins, and is
programmable with the Arduino IDE (Integrated Development Environment), via a type B USB
cable. It can be powered by the USB cable or by an external 9-volt battery, though it accepts
voltages between 7 and 20 volts. It is similar to the Arduino Nano and Leonardo.

The major components of Arduino UNO board are as follows:

➢ USB Connector: This is a printer USB port used to load a program from the Arduino IDE onto
the Arduino board. The board can also be powered through this port.
➢ Power Port: The Arduino board can be powered through an AC-to-DC adapter or a battery. The
power source can be connected by plugging in a 2.1mm center-positive plug into the power jack of
the board.
➢ Microcontroller: It is the most prominent black rectangular chip with 28 pins. Think of it as the
brains of your Arduino. The microcontroller used on the UNO board is Atmega328P by Atmel.
Atmega328P has the following components in it:
❖ Flash memory of 32KB. The program loaded from Arduino IDE is stored here.
❖ RAM of 2KB. This is a runtime memory.
❖ CPU: It controls everything that goes on within the device. It fetches the program
instructions from flash memory and runs them with the help of RAM.
❖ Electrically Erasable Programmable Read Only Memory (EEPROM) of 1KB.
This is a type of non-volatile memory, and it keeps the data even after device restart
and reset.

➢ Analog Input Pins: The Arduino UNO board has 6 analog input pins, labeled “Analog 0 to 5.”
These pins can read the signal from an analog sensor like a temperature sensor and convert it into
a digital value so that the system understands. These pins just measure voltage and not the current
because they have very high internal resistance.
➢ Digital Pins: You can find these pins labeled “Digital 0 to 13.” These pins can be used as either
input or output pins. When used as output, these pins act as a power supply source but when used
as input pins, they read the signals from the component connected to them.
➢ Reset Switch: When this switch is clicked, it sends a logical pulse to the reset pin of the
Microcontroller, and now runs the program again from the start.
➢ Crystal Oscillator: This is a quartz crystal oscillator which ticks 16 million times a second. On
each tick, the microcontroller performs one operation, for example, addition, subtraction, etc.
➢ USB Interface Chip: Think of this as a signal translator. It converts signals in the USB level to
a level that an Arduino UNO board understands.
➢ TX RX LEDs: TX stands for transmit, and RX for receive. These are indicator LEDs which blink
whenever the UNO board is transmitting or receiving data.

Fig 01: Arduino Uno


Arduino IDE:
The Arduino IDE is an open-source software, which is used to write and upload code to
the Arduino boards. The IDE application is suitable for different operating systems such as
Windows, Mac OS X, and Linux. It supports the programming languages C and C++. Here, IDE
stands for Integrated Development Environment.

The program or code written in the Arduino IDE is often called as sketching. We need to
connect the Genuino and Arduino board with the IDE to upload the sketch written in the Arduino
IDE software. The sketch is saved with the extension '.ino'.

The Arduino IDE will appear as:

Fig 02: Arduino IDE


2) Breadboard:
A breadboard is a widely used tool to design and test circuit. You do not need to solder
wires and components to make a circuit while using a bread board. It is easier to mount components
& reuse them. Since, components are not soldered you can change your circuit design at any point
without any hassle. It consists of an array of conductive metal clips encased in a box made of white
ABS plastic, where each clip is insulated with another clips.

There are a number of holes on the plastic box, arranged in a particular fashion. A typical
bread board layout consists of two types of regions also called strips. Bus strips and socket strips.

Bus strips are usually used to provide power supply to the circuit. It consists of two
columns, one for power voltage and other for ground.

Socket strips are used to hold most of the components in a circuit. Generally, it consists of
two sections each with 5 rows and 64 columns. Every column is electrically connected from inside.

Fig 03: Breadboard

3) Jumper Wires:
Jumper wires are simply wires that have connector pins at each end, allowing them to be
used to connect two points to each other without soldering. Jumper wires are typically used with
breadboards and other prototyping tools in order to make it easy to change a circuit as needed.
Fairly simple. In fact, it doesn’t get much more basic than jumper wires.

Jumper wires typically come in three versions:

➢ male-to-male
➢ male-to-female
➢ female-to-female
The difference between each is in the end point of the wire. Male ends have a pin protruding
and can plug into things, while female ends do not and are used to plug things into. Male-to-male
jumper wires are the most common and what you likely will use most often. When connecting two
ports on a breadboard, a male-to-male wire is what you’ll need.

Fig 04: Jumper Wires

4) LED:
A light-emitting diode (LED) is a semiconductor device that emits light when an electric
current flows through it. When current passes through an LED, the electrons recombine with holes
emitting light in the process. LEDs allow the current to flow in the forward direction and blocks
the current in the reverse direction.

Fig 05: LED (Light Emitting Diode)


Light-emitting diodes are heavily doped p-n junctions. Based on the semiconductor material
used and the amount of doping, an LED will emit coloured light at a particular spectral wavelength
when forward biased. As shown in the figure, an LED is encapsulated with a transparent cover so
that emitted light can come out.

The color of an LED is determined by the material used in the semiconducting element. The
two primary materials used in LEDs are aluminum gallium indium phosphide alloys and indium
gallium nitride alloys. Aluminum alloys are used to obtain red, orange and yellow light, and indium
alloys are used to get green, blue and white light. Slight changes in the composition of these alloys
change the color of the emitted light.

Light-emitting diode (LED) is a widely used standard source of light in electrical equipment.
It has a wide range of applications ranging from your mobile phone to large advertising billboards.
They mostly find applications in devices that show the time and display different types of data.

5) Resistor:
Resistor is defined as

“A passive electrical component with two terminals that are used for either limiting or
regulating the flow of electric current in electrical circuits.”

The main purpose of resistor is to reduce the current flow and to lower the voltage in any
particular portion of the circuit. It is made of copper wires which are coiled around a ceramic rod
and the outer part of the resistor is coated with an insulating paint. The SI unit of resistor is Ohm.

Fig 06: Resistor


Circuit Diagram:

Performance Diagram:
Code:
int RED = 4;

int YELLOW = 3;

int GREEN = 2;

void setup() {

pinMode(RED, OUTPUT);

pinMode(YELLOW, OUTPUT);

pinMode(GREEN, OUTPUT);

void loop() {

digitalWrite(RED, HIGH);

digitalWrite(YELLOW, LOW);

digitalWrite(GREEN, LOW);

delay(5000);

digitalWrite(RED, LOW);

digitalWrite(YELLOW, HIGH);

digitalWrite(GREEN, LOW);

delay(2000);

digitalWrite(RED, LOW);

digitalWrite(YELLOW, LOW);

digitalWrite(GREEN, HIGH);

delay(5000); }
Experiment 02
Task:
Modify Task 1 to have an advanced green (blinking green LED) for 3 seconds before illuminating
the green LED for 5 seconds.

Parts Required:
The parts required for this task are

➢ Arduino Uno
➢ Breadboard
➢ Jumper Wires
➢ LED (Red, Yellow, Green)
➢ Resistor

1) Arduino Uno:
The Arduino Uno is an open-source microcontroller board based on the Microchip
ATmega328P microcontroller and developed by Arduino.cc and initially released in 2010. The
board is equipped with sets of digital and analog input/output (I/O) pins that may be interfaced to
various expansion boards (shields) and other circuits.

The board has 14 digital I/O pins (six capable of PWM output), 6 analog I/O pins, and is
programmable with the Arduino IDE (Integrated Development Environment), via a type B USB
cable. It can be powered by the USB cable or by an external 9-volt battery, though it accepts
voltages between 7 and 20 volts. It is similar to the Arduino Nano and Leonardo.

The major components of Arduino UNO board are as follows:

➢ USB Connector: This is a printer USB port used to load a program from the Arduino IDE onto
the Arduino board. The board can also be powered through this port.
➢ Power Port: The Arduino board can be powered through an AC-to-DC adapter or a battery. The
power source can be connected by plugging in a 2.1mm center-positive plug into the power jack of
the board.
➢ Microcontroller: It is the most prominent black rectangular chip with 28 pins. Think of it as the
brains of your Arduino. The microcontroller used on the UNO board is Atmega328P by Atmel.
Atmega328P has the following components in it:

❖ Flash memory of 32KB. The program loaded from Arduino IDE is stored here.
❖ RAM of 2KB. This is a runtime memory.
❖ CPU: It controls everything that goes on within the device. It fetches the program
instructions from flash memory and runs them with the help of RAM.
❖ Electrically Erasable Programmable Read Only Memory (EEPROM) of 1KB.
This is a type of non-volatile memory, and it keeps the data even after device restart
and reset.

➢ Analog Input Pins: The Arduino UNO board has 6 analog input pins, labeled “Analog 0 to 5.”
These pins can read the signal from an analog sensor like a temperature sensor and convert it into
a digital value so that the system understands. These pins just measure voltage and not the current
because they have very high internal resistance.
➢ Digital Pins: You can find these pins labeled “Digital 0 to 13.” These pins can be used as either
input or output pins. When used as output, these pins act as a power supply source but when used
as input pins, they read the signals from the component connected to them.
➢ Reset Switch: When this switch is clicked, it sends a logical pulse to the reset pin of the
Microcontroller, and now runs the program again from the start.
➢ Crystal Oscillator: This is a quartz crystal oscillator which ticks 16 million times a second. On
each tick, the microcontroller performs one operation, for example, addition, subtraction, etc.
➢ USB Interface Chip: Think of this as a signal translator. It converts signals in the USB level to
a level that an Arduino UNO board understands.
➢ TX RX LEDs: TX stands for transmit, and RX for receive. These are indicator LEDs which blink
whenever the UNO board is transmitting or receiving data.

Fig 01: Arduino Uno

Arduino IDE:
The Arduino IDE is an open-source software, which is used to write and upload code to
the Arduino boards. The IDE application is suitable for different operating systems such as
Windows, Mac OS X, and Linux. It supports the programming languages C and C++. Here, IDE
stands for Integrated Development Environment.

The program or code written in the Arduino IDE is often called as sketching. We need to
connect the Genuino and Arduino board with the IDE to upload the sketch written in the Arduino
IDE software. The sketch is saved with the extension '.ino'.

The Arduino IDE will appear as:

Fig 02: Arduino IDE


2) Breadboard:
A breadboard is a widely used tool to design and test circuit. You do not need to solder
wires and components to make a circuit while using a bread board. It is easier to mount components
& reuse them. Since, components are not soldered you can change your circuit design at any point
without any hassle. It consists of an array of conductive metal clips encased in a box made of white
ABS plastic, where each clip is insulated with another clips.

There are a number of holes on the plastic box, arranged in a particular fashion. A typical
bread board layout consists of two types of regions also called strips. Bus strips and socket strips.

Bus strips are usually used to provide power supply to the circuit. It consists of two
columns, one for power voltage and other for ground.

Socket strips are used to hold most of the components in a circuit. Generally, it consists of
two sections each with 5 rows and 64 columns. Every column is electrically connected from inside.

Fig 03: Breadboard

3) Jumper Wires:
Jumper wires are simply wires that have connector pins at each end, allowing them to be
used to connect two points to each other without soldering. Jumper wires are typically used with
breadboards and other prototyping tools in order to make it easy to change a circuit as needed.
Fairly simple. In fact, it doesn’t get much more basic than jumper wires.

Jumper wires typically come in three versions:

➢ male-to-male
➢ male-to-female
➢ female-to-female
The difference between each is in the end point of the wire. Male ends have a pin protruding
and can plug into things, while female ends do not and are used to plug things into. Male-to-male
jumper wires are the most common and what you likely will use most often. When connecting two
ports on a breadboard, a male-to-male wire is what you’ll need.

Fig 04: Jumper Wires

4) LED:
A light-emitting diode (LED) is a semiconductor device that emits light when an electric
current flows through it. When current passes through an LED, the electrons recombine with holes
emitting light in the process. LEDs allow the current to flow in the forward direction and blocks
the current in the reverse direction.

Fig 05: LED (Light Emitting Diode)


Light-emitting diodes are heavily doped p-n junctions. Based on the semiconductor material
used and the amount of doping, an LED will emit coloured light at a particular spectral wavelength
when forward biased. As shown in the figure, an LED is encapsulated with a transparent cover so
that emitted light can come out.

The color of an LED is determined by the material used in the semiconducting element. The
two primary materials used in LEDs are aluminum gallium indium phosphide alloys and indium
gallium nitride alloys. Aluminum alloys are used to obtain red, orange and yellow light, and indium
alloys are used to get green, blue and white light. Slight changes in the composition of these alloys
change the color of the emitted light.

Light-emitting diode (LED) is a widely used standard source of light in electrical equipment.
It has a wide range of applications ranging from your mobile phone to large advertising billboards.
They mostly find applications in devices that show the time and display different types of data.

5) Resistor:
Resistor is defined as

“A passive electrical component with two terminals that are used for either limiting or
regulating the flow of electric current in electrical circuits.”

The main purpose of resistor is to reduce the current flow and to lower the voltage in any
particular portion of the circuit. It is made of copper wires which are coiled around a ceramic rod
and the outer part of the resistor is coated with an insulating paint. The SI unit of resistor is Ohm.

Fig 06: Resistor


Circuit Diagram:

Performance Diagram:
Code:
int RED = 4;

int YELLOW = 3;

int GREEN = 2;

void setup() {

pinMode(RED, OUTPUT);

pinMode(YELLOW, OUTPUT);

pinMode(GREEN, OUTPUT);

void loop() {

digitalWrite(RED, HIGH);

digitalWrite(YELLOW, LOW);

digitalWrite(GREEN, LOW);

delay(5000);

digitalWrite(RED, LOW);

digitalWrite(YELLOW, HIGH);

digitalWrite(GREEN, LOW);

delay(2000);

digitalWrite(RED, LOW);

digitalWrite(YELLOW, LOW);

digitalWrite(GREEN, HIGH);
delay(5000);

digitalWrite(GREEN, LOW);

delay(500);

digitalWrite(GREEN, HIGH);

delay(500);

digitalWrite(GREEN, LOW);

delay(500);

digitalWrite(GREEN, HIGH);

delay(500);

digitalWrite(GREEN, LOW);

delay(500);

digitalWrite(GREEN, HIGH);

delay(500);

}
Experiment 03
Task:
Create a dimmer switch by adding a potentiometer to control the brightness of LED, more over
attach a push button on the bread board for controlling the LED (on or off).

Parts Required:
The parts required for this task are

➢ Arduino Uno
➢ Breadboard
➢ Jumper Wires
➢ LED
➢ Resistor
➢ Potentiometer
➢ Push Button

1) Arduino Uno:
The Arduino Uno is an open-source microcontroller board based on the Microchip
ATmega328P microcontroller and developed by Arduino.cc and initially released in 2010. The
board is equipped with sets of digital and analog input/output (I/O) pins that may be interfaced to
various expansion boards (shields) and other circuits.

The board has 14 digital I/O pins (six capable of PWM output), 6 analog I/O pins, and is
programmable with the Arduino IDE (Integrated Development Environment), via a type B USB
cable. It can be powered by the USB cable or by an external 9-volt battery, though it accepts
voltages between 7 and 20 volts. It is similar to the Arduino Nano and Leonardo.

The major components of Arduino UNO board are as follows:

➢ USB Connector: This is a printer USB port used to load a program from the Arduino IDE onto
the Arduino board. The board can also be powered through this port.
➢ Power Port: The Arduino board can be powered through an AC-to-DC adapter or a battery. The
power source can be connected by plugging in a 2.1mm center-positive plug into the power jack of
the board.
➢ Microcontroller: It is the most prominent black rectangular chip with 28 pins. Think of it as the
brains of your Arduino. The microcontroller used on the UNO board is Atmega328P by Atmel.
Atmega328P has the following components in it:

❖ Flash memory of 32KB. The program loaded from Arduino IDE is stored here.
❖ RAM of 2KB. This is a runtime memory.
❖ CPU: It controls everything that goes on within the device. It fetches the program
instructions from flash memory and runs them with the help of RAM.
❖ Electrically Erasable Programmable Read Only Memory (EEPROM) of 1KB.
This is a type of non-volatile memory, and it keeps the data even after device restart
and reset.

➢ Analog Input Pins: The Arduino UNO board has 6 analog input pins, labeled “Analog 0 to 5.”
These pins can read the signal from an analog sensor like a temperature sensor and convert it into
a digital value so that the system understands. These pins just measure voltage and not the current
because they have very high internal resistance.
➢ Digital Pins: You can find these pins labeled “Digital 0 to 13.” These pins can be used as either
input or output pins. When used as output, these pins act as a power supply source but when used
as input pins, they read the signals from the component connected to them.
➢ Reset Switch: When this switch is clicked, it sends a logical pulse to the reset pin of the
Microcontroller, and now runs the program again from the start.
➢ Crystal Oscillator: This is a quartz crystal oscillator which ticks 16 million times a second. On
each tick, the microcontroller performs one operation, for example, addition, subtraction, etc.
➢ USB Interface Chip: Think of this as a signal translator. It converts signals in the USB level to
a level that an Arduino UNO board understands.
➢ TX RX LEDs: TX stands for transmit, and RX for receive. These are indicator LEDs which blink
whenever the UNO board is transmitting or receiving data.

Fig 01: Arduino Uno


Arduino IDE:
The Arduino IDE is an open-source software, which is used to write and upload code to
the Arduino boards. The IDE application is suitable for different operating systems such as
Windows, Mac OS X, and Linux. It supports the programming languages C and C++. Here, IDE
stands for Integrated Development Environment.

The program or code written in the Arduino IDE is often called as sketching. We need to
connect the Genuino and Arduino board with the IDE to upload the sketch written in the Arduino
IDE software. The sketch is saved with the extension '.ino'.

The Arduino IDE will appear as:

Fig 02: Arduino IDE


2) Breadboard:
A breadboard is a widely used tool to design and test circuit. You do not need to solder
wires and components to make a circuit while using a bread board. It is easier to mount components
& reuse them. Since, components are not soldered you can change your circuit design at any point
without any hassle. It consists of an array of conductive metal clips encased in a box made of white
ABS plastic, where each clip is insulated with another clips.

There are a number of holes on the plastic box, arranged in a particular fashion. A typical
bread board layout consists of two types of regions also called strips. Bus strips and socket strips.

Bus strips are usually used to provide power supply to the circuit. It consists of two
columns, one for power voltage and other for ground.

Socket strips are used to hold most of the components in a circuit. Generally, it consists of
two sections each with 5 rows and 64 columns. Every column is electrically connected from inside.

Fig 03: Breadboard

3) Jumper Wires:
Jumper wires are simply wires that have connector pins at each end, allowing them to be
used to connect two points to each other without soldering. Jumper wires are typically used with
breadboards and other prototyping tools in order to make it easy to change a circuit as needed.
Fairly simple. In fact, it doesn’t get much more basic than jumper wires.

Jumper wires typically come in three versions:

➢ male-to-male
➢ male-to-female
➢ female-to-female
The difference between each is in the end point of the wire. Male ends have a pin protruding
and can plug into things, while female ends do not and are used to plug things into. Male-to-male
jumper wires are the most common and what you likely will use most often. When connecting two
ports on a breadboard, a male-to-male wire is what you’ll need.

Fig 04: Jumper Wires

4) LED:
A light-emitting diode (LED) is a semiconductor device that emits light when an electric
current flows through it. When current passes through an LED, the electrons recombine with holes
emitting light in the process. LEDs allow the current to flow in the forward direction and blocks
the current in the reverse direction.

Fig 05: LED (Light Emitting Diode)


Light-emitting diodes are heavily doped p-n junctions. Based on the semiconductor material
used and the amount of doping, an LED will emit coloured light at a particular spectral wavelength
when forward biased. As shown in the figure, an LED is encapsulated with a transparent cover so
that emitted light can come out.

The color of an LED is determined by the material used in the semiconducting element. The
two primary materials used in LEDs are aluminum gallium indium phosphide alloys and indium
gallium nitride alloys. Aluminum alloys are used to obtain red, orange and yellow light, and indium
alloys are used to get green, blue and white light. Slight changes in the composition of these alloys
change the color of the emitted light.

Light-emitting diode (LED) is a widely used standard source of light in electrical equipment.
It has a wide range of applications ranging from your mobile phone to large advertising billboards.
They mostly find applications in devices that show the time and display different types of data.

5) Resistor:
Resistor is defined as

“A passive electrical component with two terminals that are used for either limiting or
regulating the flow of electric current in electrical circuits.”

The main purpose of resistor is to reduce the current flow and to lower the voltage in any
particular portion of the circuit. It is made of copper wires which are coiled around a ceramic rod
and the outer part of the resistor is coated with an insulating paint. The SI unit of resistor is Ohm.

Fig 06: Resistor

6) Potentiometer:
A potentiometer is a three-terminal resistor with a sliding or rotating contact that forms an
adjustable voltage divider. If only two terminals are used, one end and the wiper, it acts as a
variable resistor or rheostat.
The measuring instrument called a potentiometer is essentially a voltage divider used for
measuring electric potential (voltage); the component is an implementation of the same principle,
hence its name.

Fig 07: Potentiometer

Potentiometers are commonly used to control electrical devices such as volume controls on
audio equipment. Potentiometers operated by a mechanism can be used as position transducers,
for example, in a joystick. Potentiometers are rarely used to directly control significant power
(more than a watt), since the power dissipated in the potentiometer would be comparable to the
power in the controlled load.

7) Push Button:
A push-button (also spelled pushbutton) or simply button is a simple switch mechanism to
control some aspect of a machine or a process. Buttons are typically made out of hard material,
usually plastic or metal.

The surface is usually flat or shaped to accommodate the human finger or hand, so as to be
easily depressed or pushed. Buttons are most often biased switches, although many un-biased
buttons still require a spring to return to their un-pushed state. Terms for the "pushing" of a button
include pressing, depressing, mashing, slapping, hitting, and punching.

Fig 08: Push Buttons


Circuit Diagram:

Performance Diagram:
Code:
int pot = A0;

int led = 6;

int value;

int brightness;

void setup() {

pinMode(pot, INPUT);

pinMode(led, OUTPUT);

void loop() {

value = analogRead(pot);

brightness = map(pot, 0, 1023, 0, 255);

analogWrite(led, brightness);

}
Experiment 04
Task:
Make a circuit composed of infra-red sensor or ultra-sonic sensor for the presence of any intruder
in the area of concern. (Use of proximity)

Parts Required:
The parts required for this task are

➢ Arduino Uno
➢ Breadboard
➢ Jumper Wires
➢ Ultrasonic Sensor
➢ Buzzer

1) Arduino Uno:
The Arduino Uno is an open-source microcontroller board based on the Microchip
ATmega328P microcontroller and developed by Arduino.cc and initially released in 2010. The
board is equipped with sets of digital and analog input/output (I/O) pins that may be interfaced to
various expansion boards (shields) and other circuits.

The board has 14 digital I/O pins (six capable of PWM output), 6 analog I/O pins, and is
programmable with the Arduino IDE (Integrated Development Environment), via a type B USB
cable. It can be powered by the USB cable or by an external 9-volt battery, though it accepts
voltages between 7 and 20 volts. It is similar to the Arduino Nano and Leonardo.

The major components of Arduino UNO board are as follows:

➢ USB Connector: This is a printer USB port used to load a program from the Arduino IDE onto
the Arduino board. The board can also be powered through this port.
➢ Power Port: The Arduino board can be powered through an AC-to-DC adapter or a battery. The
power source can be connected by plugging in a 2.1mm center-positive plug into the power jack of
the board.
➢ Microcontroller: It is the most prominent black rectangular chip with 28 pins. Think of it as the
brains of your Arduino. The microcontroller used on the UNO board is Atmega328P by Atmel.
Atmega328P has the following components in it:

❖ Flash memory of 32KB. The program loaded from Arduino IDE is stored here.
❖ RAM of 2KB. This is a runtime memory.
❖ CPU: It controls everything that goes on within the device. It fetches the program
instructions from flash memory and runs them with the help of RAM.
❖ Electrically Erasable Programmable Read Only Memory (EEPROM) of 1KB.
This is a type of non-volatile memory, and it keeps the data even after device restart
and reset.

➢ Analog Input Pins: The Arduino UNO board has 6 analog input pins, labeled “Analog 0 to 5.”
These pins can read the signal from an analog sensor like a temperature sensor and convert it into
a digital value so that the system understands. These pins just measure voltage and not the current
because they have very high internal resistance.
➢ Digital Pins: You can find these pins labeled “Digital 0 to 13.” These pins can be used as either
input or output pins. When used as output, these pins act as a power supply source but when used
as input pins, they read the signals from the component connected to them.
➢ Reset Switch: When this switch is clicked, it sends a logical pulse to the reset pin of the
Microcontroller, and now runs the program again from the start.
➢ Crystal Oscillator: This is a quartz crystal oscillator which ticks 16 million times a second. On
each tick, the microcontroller performs one operation, for example, addition, subtraction, etc.
➢ USB Interface Chip: Think of this as a signal translator. It converts signals in the USB level to
a level that an Arduino UNO board understands.
➢ TX RX LEDs: TX stands for transmit, and RX for receive. These are indicator LEDs which blink
whenever the UNO board is transmitting or receiving data.

Fig 01: Arduino Uno


Arduino IDE:
The Arduino IDE is an open-source software, which is used to write and upload code to
the Arduino boards. The IDE application is suitable for different operating systems such as
Windows, Mac OS X, and Linux. It supports the programming languages C and C++. Here, IDE
stands for Integrated Development Environment.

The program or code written in the Arduino IDE is often called as sketching. We need to
connect the Genuino and Arduino board with the IDE to upload the sketch written in the Arduino
IDE software. The sketch is saved with the extension '.ino'.

The Arduino IDE will appear as:

Fig 02: Arduino IDE


2) Breadboard:
A breadboard is a widely used tool to design and test circuit. You do not need to solder
wires and components to make a circuit while using a bread board. It is easier to mount components
& reuse them. Since, components are not soldered you can change your circuit design at any point
without any hassle. It consists of an array of conductive metal clips encased in a box made of white
ABS plastic, where each clip is insulated with another clips.

There are a number of holes on the plastic box, arranged in a particular fashion. A typical
bread board layout consists of two types of regions also called strips. Bus strips and socket strips.

Bus strips are usually used to provide power supply to the circuit. It consists of two
columns, one for power voltage and other for ground.

Socket strips are used to hold most of the components in a circuit. Generally, it consists of
two sections each with 5 rows and 64 columns. Every column is electrically connected from inside.

Fig 03: Breadboard

3) Jumper Wires:
Jumper wires are simply wires that have connector pins at each end, allowing them to be
used to connect two points to each other without soldering. Jumper wires are typically used with
breadboards and other prototyping tools in order to make it easy to change a circuit as needed.
Fairly simple. In fact, it doesn’t get much more basic than jumper wires.

Jumper wires typically come in three versions:

➢ male-to-male
➢ male-to-female
➢ female-to-female
The difference between each is in the end point of the wire. Male ends have a pin protruding
and can plug into things, while female ends do not and are used to plug things into. Male-to-male
jumper wires are the most common and what you likely will use most often. When connecting two
ports on a breadboard, a male-to-male wire is what you’ll need.

Fig 04: Jumper Wires

4) Ultrasonic Sensor:
Ultrasonic sensors are electronic devices that calculate the target’s distance by emission of
ultrasonic sound waves and convert those waves into electrical signals. The speed of emitted
ultrasonic waves traveling speed is faster than the audible sound.

There are mainly two essential elements which are the transmitter and receiver. Using the
piezoelectric crystals, the transmitter generates sound, and from there it travels to the target and
gets back to the receiver component.

Fig 05: Ultrasonic Sensor


To know the distance between the target and the sensor, the sensor calculates the amount of
time required for sound emission to travel from transmitter to receiver. The calculation is done as
follows:

D = 1/2 * T * C

Where,

T = time measured in seconds

C = speed of sound = 343 m/sec

Ultrasonic Sensor Pin Diagram:


The ultrasonic sensor pin diagram is:

VCC – This pin has to be connected to a power supply +5V.

TRIG – This pin is used to receive controlling signals from the Arduino board. This is the
triggering input pin of the sensor

ECHO – This pin is used for sending signals to the Arduino board where the Arduino calculates
the pulse duration to know the distance. This pin is the ECHO output of the sensor.

GND – This pin has to be connected to the ground.

Fig 06: Ultrasonic Sensor Block Diagram


5) Buzzer:
An audio signaling device like a beeper or buzzer may be electromechanical or piezoelectric or
mechanical type. The main function of this is to convert the signal from audio to sound. Generally,
it is powered through DC voltage and used in timers, alarm devices, printers, alarms, computers,
etc. Based on the various designs, it can generate different sounds like alarm, music, bell & siren.

Fig 07: Buzzer

The pin configuration of the buzzer is shown below. It includes two pins namely positive and
negative. The positive terminal of this is represented with the ‘+’ symbol or a longer terminal. This
terminal is powered through 6 Volts whereas the negative terminal is represented with the ‘-‘
symbol or short terminal and it is connected to the GND terminal.
Circuit Diagram:

Performance Diagram:
Code:
int trigPin = 3;

int echoPin = 2;

int buzzerPin = 10;

int duration;

int distance;

void setup(){

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

pinMode(buzzPin, OUTPUT);

void loop(){

digitalWrite(trigPin, HIGH);

delay(8);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distance = (duration/2) / 29.1; // 29.1 is speed of sound

if (distance <= 20) {

digitalWrite(buzzerPin, HIGH);

}
else {

digitalWrite(buzzerPin, LOW);

}
Experiment 05
Task:
Introduce a new sensor and compile the code that detects moisture levels of a plant and set any
LED or sound attached with it for indication that plant needs watering.

Parts Required:
The parts required for this task are

➢ Arduino Uno
➢ Breadboard
➢ Jumper Wires
➢ LED
➢ Resistor
➢ Soil Moisture Sensor

1) Arduino Uno:
The Arduino Uno is an open-source microcontroller board based on the Microchip
ATmega328P microcontroller and developed by Arduino.cc and initially released in 2010. The
board is equipped with sets of digital and analog input/output (I/O) pins that may be interfaced to
various expansion boards (shields) and other circuits.

The board has 14 digital I/O pins (six capable of PWM output), 6 analog I/O pins, and is
programmable with the Arduino IDE (Integrated Development Environment), via a type B USB
cable. It can be powered by the USB cable or by an external 9-volt battery, though it accepts
voltages between 7 and 20 volts. It is similar to the Arduino Nano and Leonardo.

The major components of Arduino UNO board are as follows:

➢ USB Connector: This is a printer USB port used to load a program from the Arduino IDE onto
the Arduino board. The board can also be powered through this port.
➢ Power Port: The Arduino board can be powered through an AC-to-DC adapter or a battery. The
power source can be connected by plugging in a 2.1mm center-positive plug into the power jack of
the board.
➢ Microcontroller: It is the most prominent black rectangular chip with 28 pins. Think of it as the
brains of your Arduino. The microcontroller used on the UNO board is Atmega328P by Atmel.
Atmega328P has the following components in it:

❖ Flash memory of 32KB. The program loaded from Arduino IDE is stored here.
❖ RAM of 2KB. This is a runtime memory.
❖ CPU: It controls everything that goes on within the device. It fetches the program
instructions from flash memory and runs them with the help of RAM.
❖ Electrically Erasable Programmable Read Only Memory (EEPROM) of 1KB.
This is a type of non-volatile memory, and it keeps the data even after device restart
and reset.

➢ Analog Input Pins: The Arduino UNO board has 6 analog input pins, labeled “Analog 0 to 5.”
These pins can read the signal from an analog sensor like a temperature sensor and convert it into
a digital value so that the system understands. These pins just measure voltage and not the current
because they have very high internal resistance.
➢ Digital Pins: You can find these pins labeled “Digital 0 to 13.” These pins can be used as either
input or output pins. When used as output, these pins act as a power supply source but when used
as input pins, they read the signals from the component connected to them.
➢ Reset Switch: When this switch is clicked, it sends a logical pulse to the reset pin of the
Microcontroller, and now runs the program again from the start.
➢ Crystal Oscillator: This is a quartz crystal oscillator which ticks 16 million times a second. On
each tick, the microcontroller performs one operation, for example, addition, subtraction, etc.
➢ USB Interface Chip: Think of this as a signal translator. It converts signals in the USB level to
a level that an Arduino UNO board understands.
➢ TX RX LEDs: TX stands for transmit, and RX for receive. These are indicator LEDs which blink
whenever the UNO board is transmitting or receiving data.

Fig 01: Arduino Uno

Arduino IDE:
The Arduino IDE is an open-source software, which is used to write and upload code to
the Arduino boards. The IDE application is suitable for different operating systems such as
Windows, Mac OS X, and Linux. It supports the programming languages C and C++. Here, IDE
stands for Integrated Development Environment.

The program or code written in the Arduino IDE is often called as sketching. We need to
connect the Genuino and Arduino board with the IDE to upload the sketch written in the Arduino
IDE software. The sketch is saved with the extension '.ino'.

The Arduino IDE will appear as:

Fig 02: Arduino IDE


2) Breadboard:
A breadboard is a widely used tool to design and test circuit. You do not need to solder
wires and components to make a circuit while using a bread board. It is easier to mount components
& reuse them. Since, components are not soldered you can change your circuit design at any point
without any hassle. It consists of an array of conductive metal clips encased in a box made of white
ABS plastic, where each clip is insulated with another clips.

There are a number of holes on the plastic box, arranged in a particular fashion. A typical
bread board layout consists of two types of regions also called strips. Bus strips and socket strips.

Bus strips are usually used to provide power supply to the circuit. It consists of two
columns, one for power voltage and other for ground.

Socket strips are used to hold most of the components in a circuit. Generally, it consists of
two sections each with 5 rows and 64 columns. Every column is electrically connected from inside.

Fig 03: Breadboard

3) Jumper Wires:
Jumper wires are simply wires that have connector pins at each end, allowing them to be
used to connect two points to each other without soldering. Jumper wires are typically used with
breadboards and other prototyping tools in order to make it easy to change a circuit as needed.
Fairly simple. In fact, it doesn’t get much more basic than jumper wires.

Jumper wires typically come in three versions:

➢ male-to-male
➢ male-to-female
➢ female-to-female
The difference between each is in the end point of the wire. Male ends have a pin protruding
and can plug into things, while female ends do not and are used to plug things into. Male-to-male
jumper wires are the most common and what you likely will use most often. When connecting two
ports on a breadboard, a male-to-male wire is what you’ll need.

Fig 04: Jumper Wires

4) LED:
A light-emitting diode (LED) is a semiconductor device that emits light when an electric
current flows through it. When current passes through an LED, the electrons recombine with holes
emitting light in the process. LEDs allow the current to flow in the forward direction and blocks
the current in the reverse direction.

Fig 05: LED (Light Emitting Diode)


Light-emitting diodes are heavily doped p-n junctions. Based on the semiconductor material
used and the amount of doping, an LED will emit coloured light at a particular spectral wavelength
when forward biased. As shown in the figure, an LED is encapsulated with a transparent cover so
that emitted light can come out.

The color of an LED is determined by the material used in the semiconducting element. The
two primary materials used in LEDs are aluminum gallium indium phosphide alloys and indium
gallium nitride alloys. Aluminum alloys are used to obtain red, orange and yellow light, and indium
alloys are used to get green, blue and white light. Slight changes in the composition of these alloys
change the color of the emitted light.

Light-emitting diode (LED) is a widely used standard source of light in electrical equipment.
It has a wide range of applications ranging from your mobile phone to large advertising billboards.
They mostly find applications in devices that show the time and display different types of data.

5) Resistor:
Resistor is defined as

“A passive electrical component with two terminals that are used for either limiting or
regulating the flow of electric current in electrical circuits.”

The main purpose of resistor is to reduce the current flow and to lower the voltage in any
particular portion of the circuit. It is made of copper wires which are coiled around a ceramic rod
and the outer part of the resistor is coated with an insulating paint. The SI unit of resistor is Ohm.

Fig 06: Resistor

6) Soil Moisture Sensor:


The soil moisture sensor is one kind of sensor used to gauge the volumetric content of water
within the soil. As the straight gravimetric dimension of soil moisture needs eliminating, drying,
as well as sample weighting. These sensors measure the volumetric water content not directly with
the help of some other rules of soil like dielectric constant, electrical resistance, otherwise
interaction with neutrons, and replacement of the moisture content.
The relation among the calculated property as well as moisture of soil should be adjusted &
may change based on ecological factors like temperature, type of soil, otherwise electric
conductivity. The microwave emission which is reflected can be influenced by the moisture of soil
as well as mainly used in agriculture and remote sensing within hydrology.

Fig 07: Soil Moisture Sensor

These sensors normally used to check volumetric water content, and another group of sensors
calculates a new property of moisture within soils named water potential. Generally, these sensors
are named as soil water potential sensors which include gypsum blocks and tensiometer.
Circuit Diagram:

Performance Diagram:
Code:
int msensor = A1;

int led = 13;

int msvalue;

void setup() {

pinMode(msensor, INPUT);

pinMode(led, OUTPUT);

void loop() {

msvalue = analogRead(msensor);

if ((msvalue >= 500)){

digitalWrite(led, HIGH);

else if ((msvalue <= 300)){

digitalWrite(led, LOW);

}
Experiment 06
Task:
Introduce the keypad to your Arduino by building a keypad entry system. (Locking or unlocking
any case by password).

Parts Required:
The parts required for this task are

➢ Arduino Uno
➢ Breadboard
➢ Jumper Wires
➢ LED
➢ Resistor
➢ Keypad (4x4)

1) Arduino Uno:
The Arduino Uno is an open-source microcontroller board based on the Microchip
ATmega328P microcontroller and developed by Arduino.cc and initially released in 2010. The
board is equipped with sets of digital and analog input/output (I/O) pins that may be interfaced to
various expansion boards (shields) and other circuits.

The board has 14 digital I/O pins (six capable of PWM output), 6 analog I/O pins, and is
programmable with the Arduino IDE (Integrated Development Environment), via a type B USB
cable. It can be powered by the USB cable or by an external 9-volt battery, though it accepts
voltages between 7 and 20 volts. It is similar to the Arduino Nano and Leonardo.

The major components of Arduino UNO board are as follows:

➢ USB Connector: This is a printer USB port used to load a program from the Arduino IDE onto
the Arduino board. The board can also be powered through this port.
➢ Power Port: The Arduino board can be powered through an AC-to-DC adapter or a battery. The
power source can be connected by plugging in a 2.1mm center-positive plug into the power jack of
the board.
➢ Microcontroller: It is the most prominent black rectangular chip with 28 pins. Think of it as the
brains of your Arduino. The microcontroller used on the UNO board is Atmega328P by Atmel.
Atmega328P has the following components in it:

❖ Flash memory of 32KB. The program loaded from Arduino IDE is stored here.
❖ RAM of 2KB. This is a runtime memory.
❖ CPU: It controls everything that goes on within the device. It fetches the program
instructions from flash memory and runs them with the help of RAM.
❖ Electrically Erasable Programmable Read Only Memory (EEPROM) of 1KB.
This is a type of non-volatile memory, and it keeps the data even after device restart
and reset.

➢ Analog Input Pins: The Arduino UNO board has 6 analog input pins, labeled “Analog 0 to 5.”
These pins can read the signal from an analog sensor like a temperature sensor and convert it into
a digital value so that the system understands. These pins just measure voltage and not the current
because they have very high internal resistance.
➢ Digital Pins: You can find these pins labeled “Digital 0 to 13.” These pins can be used as either
input or output pins. When used as output, these pins act as a power supply source but when used
as input pins, they read the signals from the component connected to them.
➢ Reset Switch: When this switch is clicked, it sends a logical pulse to the reset pin of the
Microcontroller, and now runs the program again from the start.
➢ Crystal Oscillator: This is a quartz crystal oscillator which ticks 16 million times a second. On
each tick, the microcontroller performs one operation, for example, addition, subtraction, etc.
➢ USB Interface Chip: Think of this as a signal translator. It converts signals in the USB level to
a level that an Arduino UNO board understands.
➢ TX RX LEDs: TX stands for transmit, and RX for receive. These are indicator LEDs which blink
whenever the UNO board is transmitting or receiving data.

Fig 01: Arduino Uno

Arduino IDE:
The Arduino IDE is an open-source software, which is used to write and upload code to
the Arduino boards. The IDE application is suitable for different operating systems such as
Windows, Mac OS X, and Linux. It supports the programming languages C and C++. Here, IDE
stands for Integrated Development Environment.

The program or code written in the Arduino IDE is often called as sketching. We need to
connect the Genuino and Arduino board with the IDE to upload the sketch written in the Arduino
IDE software. The sketch is saved with the extension '.ino'.

The Arduino IDE will appear as:

Fig 02: Arduino IDE


2) Breadboard:
A breadboard is a widely used tool to design and test circuit. You do not need to solder
wires and components to make a circuit while using a bread board. It is easier to mount components
& reuse them. Since, components are not soldered you can change your circuit design at any point
without any hassle. It consists of an array of conductive metal clips encased in a box made of white
ABS plastic, where each clip is insulated with another clips.

There are a number of holes on the plastic box, arranged in a particular fashion. A typical
bread board layout consists of two types of regions also called strips. Bus strips and socket strips.

Bus strips are usually used to provide power supply to the circuit. It consists of two
columns, one for power voltage and other for ground.

Socket strips are used to hold most of the components in a circuit. Generally, it consists of
two sections each with 5 rows and 64 columns. Every column is electrically connected from inside.

Fig 03: Breadboard

3) Jumper Wires:
Jumper wires are simply wires that have connector pins at each end, allowing them to be
used to connect two points to each other without soldering. Jumper wires are typically used with
breadboards and other prototyping tools in order to make it easy to change a circuit as needed.
Fairly simple. In fact, it doesn’t get much more basic than jumper wires.

Jumper wires typically come in three versions:

➢ male-to-male
➢ male-to-female
➢ female-to-female
The difference between each is in the end point of the wire. Male ends have a pin protruding
and can plug into things, while female ends do not and are used to plug things into. Male-to-male
jumper wires are the most common and what you likely will use most often. When connecting two
ports on a breadboard, a male-to-male wire is what you’ll need.

Fig 04: Jumper Wires

4) LED:
A light-emitting diode (LED) is a semiconductor device that emits light when an electric
current flows through it. When current passes through an LED, the electrons recombine with holes
emitting light in the process. LEDs allow the current to flow in the forward direction and blocks
the current in the reverse direction.

Fig 05: LED (Light Emitting Diode)


Light-emitting diodes are heavily doped p-n junctions. Based on the semiconductor material
used and the amount of doping, an LED will emit coloured light at a particular spectral wavelength
when forward biased. As shown in the figure, an LED is encapsulated with a transparent cover so
that emitted light can come out.

The color of an LED is determined by the material used in the semiconducting element. The
two primary materials used in LEDs are aluminum gallium indium phosphide alloys and indium
gallium nitride alloys. Aluminum alloys are used to obtain red, orange and yellow light, and indium
alloys are used to get green, blue and white light. Slight changes in the composition of these alloys
change the color of the emitted light.

Light-emitting diode (LED) is a widely used standard source of light in electrical equipment.
It has a wide range of applications ranging from your mobile phone to large advertising billboards.
They mostly find applications in devices that show the time and display different types of data.

5) Resistor:
Resistor is defined as

“A passive electrical component with two terminals that are used for either limiting or
regulating the flow of electric current in electrical circuits.”

The main purpose of resistor is to reduce the current flow and to lower the voltage in any
particular portion of the circuit. It is made of copper wires which are coiled around a ceramic rod
and the outer part of the resistor is coated with an insulating paint. The SI unit of resistor is Ohm.

Fig 06: Resistor

6) Keypad:
Keypad is used as an input device to read the key pressed by the user and to process it. 4x4
keypad consists of 4 rows and 4 columns. Switches are placed between the rows and columns.

A key press establishes a connection between the corresponding row and column, between
which the switch is placed.
Fig 07: 4x4 Keypad

As given in above table, a 4x4 keypad will have eight terminals. In them four are rows of
matrix and four are columns of matrix. These 8 pins are driven out from 16 buttons present in the
module. Those 16 alphanumeric digits on the module surface are the 16 buttons arranged in matrix
formation. The internal structure of 4x4 keypad module is shown below.
Circuit Diagram:

Performance Diagram:
Code:
#include <Keypad.h>

char * password = "1416";

int position = 0;

const byte ROWS = 4;

const byte COLS = 4;

char keys[ROWS][COLS] =

{'1','2','3','A'},

{'4','5','6','B'},

{'7','8','9','C'},

{'*','0','#','D'}

}; //mapping of the keys done w.r.t to the grid keypad

byte rowPins[ROWS] = { 11, 10, 9, 8 };

byte colPins[COLS] = { 5, 4, 3, 2 };

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

int red = 12;

int green = 13;

void setup() {
pinMode(red, OUTPUT);

pinMode(green, OUTPUT);

digitalWrite(green, LOW);

digitalWrite(red, HIGH);

void loop()

char key = keypad.getKey();

if (key == '*' || key == 'A')

position = 0;

digitalWrite(green, LOW);

digitalWrite(red, HIGH);

if (key == password[position])

position ++;

if (position == 4)

{
digitalWrite(green, HIGH);

digitalWrite(red, LOW);

delay(100);

}
Experiment 07
Task:
Make Arduino based controlling of power through light sensor (will be used in solar tracking).

Parts Required:
The parts required for this task are

➢ Arduino Uno
➢ Breadboard
➢ Jumper Wires
➢ LED
➢ Resistor
➢ Light Sensor

1) Arduino Uno:
The Arduino Uno is an open-source microcontroller board based on the Microchip
ATmega328P microcontroller and developed by Arduino.cc and initially released in 2010. The
board is equipped with sets of digital and analog input/output (I/O) pins that may be interfaced to
various expansion boards (shields) and other circuits.

The board has 14 digital I/O pins (six capable of PWM output), 6 analog I/O pins, and is
programmable with the Arduino IDE (Integrated Development Environment), via a type B USB
cable. It can be powered by the USB cable or by an external 9-volt battery, though it accepts
voltages between 7 and 20 volts. It is similar to the Arduino Nano and Leonardo.

The major components of Arduino UNO board are as follows:

➢ USB Connector: This is a printer USB port used to load a program from the Arduino IDE onto
the Arduino board. The board can also be powered through this port.
➢ Power Port: The Arduino board can be powered through an AC-to-DC adapter or a battery. The
power source can be connected by plugging in a 2.1mm center-positive plug into the power jack of
the board.
➢ Microcontroller: It is the most prominent black rectangular chip with 28 pins. Think of it as the
brains of your Arduino. The microcontroller used on the UNO board is Atmega328P by Atmel.
Atmega328P has the following components in it:

❖ Flash memory of 32KB. The program loaded from Arduino IDE is stored here.
❖ RAM of 2KB. This is a runtime memory.
❖ CPU: It controls everything that goes on within the device. It fetches the program
instructions from flash memory and runs them with the help of RAM.
❖ Electrically Erasable Programmable Read Only Memory (EEPROM) of 1KB.
This is a type of non-volatile memory, and it keeps the data even after device restart
and reset.

➢ Analog Input Pins: The Arduino UNO board has 6 analog input pins, labeled “Analog 0 to 5.”
These pins can read the signal from an analog sensor like a temperature sensor and convert it into
a digital value so that the system understands. These pins just measure voltage and not the current
because they have very high internal resistance.
➢ Digital Pins: You can find these pins labeled “Digital 0 to 13.” These pins can be used as either
input or output pins. When used as output, these pins act as a power supply source but when used
as input pins, they read the signals from the component connected to them.
➢ Reset Switch: When this switch is clicked, it sends a logical pulse to the reset pin of the
Microcontroller, and now runs the program again from the start.
➢ Crystal Oscillator: This is a quartz crystal oscillator which ticks 16 million times a second. On
each tick, the microcontroller performs one operation, for example, addition, subtraction, etc.
➢ USB Interface Chip: Think of this as a signal translator. It converts signals in the USB level to
a level that an Arduino UNO board understands.
➢ TX RX LEDs: TX stands for transmit, and RX for receive. These are indicator LEDs which blink
whenever the UNO board is transmitting or receiving data.

Fig 01: Arduino Uno

Arduino IDE:
The Arduino IDE is an open-source software, which is used to write and upload code to
the Arduino boards. The IDE application is suitable for different operating systems such as
Windows, Mac OS X, and Linux. It supports the programming languages C and C++. Here, IDE
stands for Integrated Development Environment.

The program or code written in the Arduino IDE is often called as sketching. We need to
connect the Genuino and Arduino board with the IDE to upload the sketch written in the Arduino
IDE software. The sketch is saved with the extension '.ino'.

The Arduino IDE will appear as:

Fig 02: Arduino IDE


2) Breadboard:
A breadboard is a widely used tool to design and test circuit. You do not need to solder
wires and components to make a circuit while using a bread board. It is easier to mount components
& reuse them. Since, components are not soldered you can change your circuit design at any point
without any hassle. It consists of an array of conductive metal clips encased in a box made of white
ABS plastic, where each clip is insulated with another clips.

There are a number of holes on the plastic box, arranged in a particular fashion. A typical
bread board layout consists of two types of regions also called strips. Bus strips and socket strips.

Bus strips are usually used to provide power supply to the circuit. It consists of two
columns, one for power voltage and other for ground.

Socket strips are used to hold most of the components in a circuit. Generally, it consists of
two sections each with 5 rows and 64 columns. Every column is electrically connected from inside.

Fig 03: Breadboard

3) Jumper Wires:
Jumper wires are simply wires that have connector pins at each end, allowing them to be
used to connect two points to each other without soldering. Jumper wires are typically used with
breadboards and other prototyping tools in order to make it easy to change a circuit as needed.
Fairly simple. In fact, it doesn’t get much more basic than jumper wires.

Jumper wires typically come in three versions:

➢ male-to-male
➢ male-to-female
➢ female-to-female
The difference between each is in the end point of the wire. Male ends have a pin protruding
and can plug into things, while female ends do not and are used to plug things into. Male-to-male
jumper wires are the most common and what you likely will use most often. When connecting two
ports on a breadboard, a male-to-male wire is what you’ll need.

Fig 04: Jumper Wires

4) LED:
A light-emitting diode (LED) is a semiconductor device that emits light when an electric
current flows through it. When current passes through an LED, the electrons recombine with holes
emitting light in the process. LEDs allow the current to flow in the forward direction and blocks
the current in the reverse direction.

Fig 05: LED (Light Emitting Diode)


Light-emitting diodes are heavily doped p-n junctions. Based on the semiconductor material
used and the amount of doping, an LED will emit colored light at a particular spectral wavelength
when forward biased. As shown in the figure, an LED is encapsulated with a transparent cover so
that emitted light can come out.

The color of an LED is determined by the material used in the semiconducting element. The
two primary materials used in LEDs are aluminum gallium indium phosphide alloys and indium
gallium nitride alloys. Aluminum alloys are used to obtain red, orange and yellow light, and indium
alloys are used to get green, blue and white light. Slight changes in the composition of these alloys
change the color of the emitted light.

Light-emitting diode (LED) is a widely used standard source of light in electrical equipment.
It has a wide range of applications ranging from your mobile phone to large advertising billboards.
They mostly find applications in devices that show the time and display different types of data.

5) Resistor:
Resistor is defined as

“A passive electrical component with two terminals that are used for either limiting or
regulating the flow of electric current in electrical circuits.”

The main purpose of resistor is to reduce the current flow and to lower the voltage in any
particular portion of the circuit. It is made of copper wires which are coiled around a ceramic rod
and the outer part of the resistor is coated with an insulating paint. The SI unit of resistor is Ohm.

Fig 06: Resistor

6) Light Sensor:
A Light Sensor generates an output signal indicating the intensity of light by measuring the
radiant energy that exists in a very narrow range of frequencies basically called “light”, and which
ranges in frequency from “Infra-red” to “Visible” up to “Ultraviolet” light spectrum.
The light sensor is a passive device that convert this “light energy” whether visible or in the
infra-red parts of the spectrum into an electrical signal output. Light sensors are more commonly
known as “Photoelectric Devices” or “Photo Sensors” because the convert light energy (photons)
into electricity (electrons).

Fig 07: Light Sensor


Circuit Diagram:

Performance Diagram:
Code:
int ledPin = 13;

int ldrPin = A0;

void setup() {

pinMode(ledPin, OUTPUT);

pinMode(ldrPin, INPUT);

void loop() {

int ldrStatus = analogRead(ldrPin);

if (ldrStatus <= 400)

digitalWrite(ledPin, HIGH);

else {

digitalWrite(ledPin, LOW);

}
Experiment 08
Task:
Make Arduino based digital thermometer and show its value on LCD display.

Parts Required:
The parts required for this task are

➢ Arduino Uno
➢ Breadboard
➢ Jumper Wires
➢ Temperature Sensor
➢ Standard LCD Display (16x2)

1) Arduino Uno:
The Arduino Uno is an open-source microcontroller board based on the Microchip
ATmega328P microcontroller and developed by Arduino.cc and initially released in 2010. The
board is equipped with sets of digital and analog input/output (I/O) pins that may be interfaced to
various expansion boards (shields) and other circuits.

The board has 14 digital I/O pins (six capable of PWM output), 6 analog I/O pins, and is
programmable with the Arduino IDE (Integrated Development Environment), via a type B USB
cable. It can be powered by the USB cable or by an external 9-volt battery, though it accepts
voltages between 7 and 20 volts. It is similar to the Arduino Nano and Leonardo.

The major components of Arduino UNO board are as follows:

➢ USB Connector: This is a printer USB port used to load a program from the Arduino IDE onto
the Arduino board. The board can also be powered through this port.
➢ Power Port: The Arduino board can be powered through an AC-to-DC adapter or a battery. The
power source can be connected by plugging in a 2.1mm center-positive plug into the power jack of
the board.
➢ Microcontroller: It is the most prominent black rectangular chip with 28 pins. Think of it as the
brains of your Arduino. The microcontroller used on the UNO board is Atmega328P by Atmel.
Atmega328P has the following components in it:

❖ Flash memory of 32KB. The program loaded from Arduino IDE is stored here.
❖ RAM of 2KB. This is a runtime memory.
❖ CPU: It controls everything that goes on within the device. It fetches the program
instructions from flash memory and runs them with the help of RAM.
❖ Electrically Erasable Programmable Read Only Memory (EEPROM) of 1KB.
This is a type of non-volatile memory, and it keeps the data even after device restart
and reset.

➢ Analog Input Pins: The Arduino UNO board has 6 analog input pins, labeled “Analog 0 to 5.”
These pins can read the signal from an analog sensor like a temperature sensor and convert it into
a digital value so that the system understands. These pins just measure voltage and not the current
because they have very high internal resistance.
➢ Digital Pins: You can find these pins labeled “Digital 0 to 13.” These pins can be used as either
input or output pins. When used as output, these pins act as a power supply source but when used
as input pins, they read the signals from the component connected to them.
➢ Reset Switch: When this switch is clicked, it sends a logical pulse to the reset pin of the
Microcontroller, and now runs the program again from the start.
➢ Crystal Oscillator: This is a quartz crystal oscillator which ticks 16 million times a second. On
each tick, the microcontroller performs one operation, for example, addition, subtraction, etc.
➢ USB Interface Chip: Think of this as a signal translator. It converts signals in the USB level to
a level that an Arduino UNO board understands.
➢ TX RX LEDs: TX stands for transmit, and RX for receive. These are indicator LEDs which blink
whenever the UNO board is transmitting or receiving data.

Fig 01: Arduino Uno

Arduino IDE:
The Arduino IDE is an open-source software, which is used to write and upload code to
the Arduino boards. The IDE application is suitable for different operating systems such as
Windows, Mac OS X, and Linux. It supports the programming languages C and C++. Here, IDE
stands for Integrated Development Environment.

The program or code written in the Arduino IDE is often called as sketching. We need to
connect the Genuino and Arduino board with the IDE to upload the sketch written in the Arduino
IDE software. The sketch is saved with the extension '.ino'.

The Arduino IDE will appear as:

Fig 02: Arduino IDE


2) Breadboard:
A breadboard is a widely used tool to design and test circuit. You do not need to solder
wires and components to make a circuit while using a bread board. It is easier to mount components
& reuse them. Since, components are not soldered you can change your circuit design at any point
without any hassle. It consists of an array of conductive metal clips encased in a box made of white
ABS plastic, where each clip is insulated with another clips.

There are a number of holes on the plastic box, arranged in a particular fashion. A typical
bread board layout consists of two types of regions also called strips. Bus strips and socket strips.

Bus strips are usually used to provide power supply to the circuit. It consists of two
columns, one for power voltage and other for ground.

Socket strips are used to hold most of the components in a circuit. Generally, it consists of
two sections each with 5 rows and 64 columns. Every column is electrically connected from inside.

Fig 03: Breadboard

3) Jumper Wires:
Jumper wires are simply wires that have connector pins at each end, allowing them to be
used to connect two points to each other without soldering. Jumper wires are typically used with
breadboards and other prototyping tools in order to make it easy to change a circuit as needed.
Fairly simple. In fact, it doesn’t get much more basic than jumper wires.

Jumper wires typically come in three versions:

➢ male-to-male
➢ male-to-female
➢ female-to-female
The difference between each is in the end point of the wire. Male ends have a pin protruding
and can plug into things, while female ends do not and are used to plug things into. Male-to-male
jumper wires are the most common and what you likely will use most often. When connecting two
ports on a breadboard, a male-to-male wire is what you’ll need.

Fig 04: Jumper Wires

4) Temperature Sensor:
A temperature sensor is a device used to measure temperature. This can be air temperature,
liquid temperature or the temperature of solid matter.

The LM35DZ is a linear temperature sensor that comes directly calibrated in Celsius. The
analog output is directly proportional to the temperature in Celsius: 10 mV per degrees Celsius
rise in temperature.

Fig 05: Temperature Sensor


This sensor is very similar with the LM335 (calibrated in Kelvin) and with
the LM34 (calibrated in Fahrenheit).

5) Standard LCD Display:


An LCD (Liquid Crystal Display) screen is an electronic display module and has a wide range
of applications. A 16x2 LCD display is very basic module and is very commonly used in various
devices and circuits. 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 5x7 pixel matrix. The 16 x 2 intelligent alphanumeric
dot matrix display is capable of displaying 224 different characters and symbols. This LCD has
two registers, namely, Command and Data.

Command registers stores various commands given to the display. Data register stores data to
be displayed. The process of controlling the display involves putting the data that form the image
of what you want to display into the data registers, then putting instructions in the instruction
register. In your Arduino project Liquid Crystal Library simplifies this for you so you don't need
to know the low-level instructions. Contrast of the display can be adjusted by adjusting the
potentiometer to be connected across VEE pin.

Fig 06: 16x2 LCD Display


Circuit Diagram:

Performance Diagram:
Code:
#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int tempPin = A0;

void setup()

lcd.begin(16,2);

void loop()

int value = analogRead(tempPin);

lcd.setCursor(0,1);

float millivolts = (value / 1024.0) * 5000;

float celsius = millivolts / 10;

lcd.clear();

lcd.setCursor(0,0);

lcd.print(celsius);

lcd.print("C");

delay(1000);

}
Experiment 09 & 10
Task:
Design the Arduino based code to control the speed of motor using potentiometer and also a code
for direction control (H bridge circuiting).

Parts Required:
The parts required for this task are

➢ Arduino Uno
➢ Breadboard
➢ Jumper Wires
➢ Diodes
➢ Resistor (100K ohm)
➢ Potentiometer
➢ Push Button
➢ Transistors
➢ DC Motor

1) Arduino Uno:
The Arduino Uno is an open-source microcontroller board based on the Microchip
ATmega328P microcontroller and developed by Arduino.cc and initially released in 2010. The
board is equipped with sets of digital and analog input/output (I/O) pins that may be interfaced to
various expansion boards (shields) and other circuits.

The board has 14 digital I/O pins (six capable of PWM output), 6 analog I/O pins, and is
programmable with the Arduino IDE (Integrated Development Environment), via a type B USB
cable. It can be powered by the USB cable or by an external 9-volt battery, though it accepts
voltages between 7 and 20 volts. It is similar to the Arduino Nano and Leonardo.

The major components of Arduino UNO board are as follows:

➢ USB Connector: This is a printer USB port used to load a program from the Arduino IDE onto
the Arduino board. The board can also be powered through this port.
➢ Power Port: The Arduino board can be powered through an AC-to-DC adapter or a battery. The
power source can be connected by plugging in a 2.1mm center-positive plug into the power jack of
the board.
➢ Microcontroller: It is the most prominent black rectangular chip with 28 pins. Think of it as the
brains of your Arduino. The microcontroller used on the UNO board is Atmega328P by Atmel.
Atmega328P has the following components in it:
❖ Flash memory of 32KB. The program loaded from Arduino IDE is stored here.
❖ RAM of 2KB. This is a runtime memory.
❖ CPU: It controls everything that goes on within the device. It fetches the program
instructions from flash memory and runs them with the help of RAM.
❖ Electrically Erasable Programmable Read Only Memory (EEPROM) of 1KB.
This is a type of non-volatile memory, and it keeps the data even after device restart
and reset.

➢ Analog Input Pins: The Arduino UNO board has 6 analog input pins, labeled “Analog 0 to 5.”
These pins can read the signal from an analog sensor like a temperature sensor and convert it into
a digital value so that the system understands. These pins just measure voltage and not the current
because they have very high internal resistance.
➢ Digital Pins: You can find these pins labeled “Digital 0 to 13.” These pins can be used as either
input or output pins. When used as output, these pins act as a power supply source but when used
as input pins, they read the signals from the component connected to them.
➢ Reset Switch: When this switch is clicked, it sends a logical pulse to the reset pin of the
Microcontroller, and now runs the program again from the start.
➢ Crystal Oscillator: This is a quartz crystal oscillator which ticks 16 million times a second. On
each tick, the microcontroller performs one operation, for example, addition, subtraction, etc.
➢ USB Interface Chip: Think of this as a signal translator. It converts signals in the USB level to
a level that an Arduino UNO board understands.
➢ TX RX LEDs: TX stands for transmit, and RX for receive. These are indicator LEDs which blink
whenever the UNO board is transmitting or receiving data.

Fig 01: Arduino Uno


Arduino IDE:
The Arduino IDE is an open-source software, which is used to write and upload code to
the Arduino boards. The IDE application is suitable for different operating systems such as
Windows, Mac OS X, and Linux. It supports the programming languages C and C++. Here, IDE
stands for Integrated Development Environment.

The program or code written in the Arduino IDE is often called as sketching. We need to
connect the Genuino and Arduino board with the IDE to upload the sketch written in the Arduino
IDE software. The sketch is saved with the extension '.ino'.

The Arduino IDE will appear as:

Fig 02: Arduino IDE


2) Breadboard:
A breadboard is a widely used tool to design and test circuit. You do not need to solder
wires and components to make a circuit while using a bread board. It is easier to mount components
& reuse them. Since, components are not soldered you can change your circuit design at any point
without any hassle. It consists of an array of conductive metal clips encased in a box made of white
ABS plastic, where each clip is insulated with another clips.

There are a number of holes on the plastic box, arranged in a particular fashion. A typical
bread board layout consists of two types of regions also called strips. Bus strips and socket strips.

Bus strips are usually used to provide power supply to the circuit. It consists of two
columns, one for power voltage and other for ground.

Socket strips are used to hold most of the components in a circuit. Generally, it consists of
two sections each with 5 rows and 64 columns. Every column is electrically connected from inside.

Fig 03: Breadboard

3) Jumper Wires:
Jumper wires are simply wires that have connector pins at each end, allowing them to be
used to connect two points to each other without soldering. Jumper wires are typically used with
breadboards and other prototyping tools in order to make it easy to change a circuit as needed.
Fairly simple. In fact, it doesn’t get much more basic than jumper wires.

Jumper wires typically come in three versions:

➢ male-to-male
➢ male-to-female
➢ female-to-female
The difference between each is in the end point of the wire. Male ends have a pin protruding
and can plug into things, while female ends do not and are used to plug things into. Male-to-male
jumper wires are the most common and what you likely will use most often. When connecting two
ports on a breadboard, a male-to-male wire is what you’ll need.

Fig 04: Jumper Wires

4) Diode:
A diode is a semiconductor device that essentially acts as a one-way switch for current. It
allows current to flow easily in one direction, but severely restricts current from flowing in the
opposite direction.

Fig 05: Diode


Diodes are also known as rectifiers because they change alternating current (ac) into pulsating
direct current (dc). Diodes are rated according to their type, voltage, and current capacity. Diodes
have polarity, determined by an anode (positive lead) and cathode (negative lead). Most diodes
allow current to flow only when positive voltage is applied to the anode.

When a diode allows current flow, it is forward-biased. When a diode is reverse-biased, it acts
as an insulator and does not permit current to flow.

Fig 06: Diode Symbol

A standard diode symbol is represented as above. In the above diagram, we can see that there
are two terminals that are known as anode and cathode. The arrowhead is the anode that represents
the direction of the conventional current flow in the forward biased condition. The other end is the
cathode.

5) Resistor:
Resistor is defined as

“A passive electrical component with two terminals that are used for either limiting or
regulating the flow of electric current in electrical circuits.”

The main purpose of resistor is to reduce the current flow and to lower the voltage in any
particular portion of the circuit. It is made of copper wires which are coiled around a ceramic rod
and the outer part of the resistor is coated with an insulating paint. The SI unit of resistor is Ohm.
Fig 07: Resistor

6) Potentiometer:
A potentiometer is a three-terminal resistor with a sliding or rotating contact that forms an
adjustable voltage divider. If only two terminals are used, one end and the wiper, it acts as a
variable resistor or rheostat.

The measuring instrument called a potentiometer is essentially a voltage divider used for
measuring electric potential (voltage); the component is an implementation of the same principle,
hence its name.

Fig 08: Potentiometer

Potentiometers are commonly used to control electrical devices such as volume controls on
audio equipment. Potentiometers operated by a mechanism can be used as position transducers,
for example, in a joystick. Potentiometers are rarely used to directly control significant power
(more than a watt), since the power dissipated in the potentiometer would be comparable to the
power in the controlled load.

7) Push Button:
A push-button (also spelled pushbutton) or simply button is a simple switch mechanism to
control some aspect of a machine or a process. Buttons are typically made out of hard material,
usually plastic or metal.

The surface is usually flat or shaped to accommodate the human finger or hand, so as to be
easily depressed or pushed. Buttons are most often biased switches, although many un-biased
buttons still require a spring to return to their un-pushed state. Terms for the "pushing" of a button
include pressing, depressing, mashing, slapping, hitting, and punching.
Fig 09: Push Buttons

8) Transistor:
A transistor is a type of a semiconductor device that can be used to both conduct and insulate
electric current or voltage. A transistor basically acts as a switch and an amplifier. In simple words,
we can say that a transistor is a miniature device that is used to control or regulate the flow of
electronic signals.

Fig 10: Transistor

Transistors are one of the key components in most of the electronic devices that are present
today. Developed in the year 1947 by three American physicists John Bardeen, Walter Brattain
and William Shockley, the transistor is considered as one of the most important inventions in the
history of science.

A typical transistor is composed of three layers of semiconductor materials or more specifically


terminals which helps to make a connection to an external circuit and carry the current. A voltage
or current that is applied to any one pair of the terminals of a transistor controls the current through
the other pair of terminals. There are three terminals for a transistor. They are:

➢ Base: This is used to activate the transistor.

➢ Collector: It is the positive lead of the transistor.

➢ Emitter: It is the negative lead of the transistor.


9) DC Motor:
A DC motor is defined as a class of electrical motors that convert direct current electrical
energy into mechanical energy. In a DC motor, the input electrical energy is the direct current
which is transformed into the mechanical rotation.

Fig 11: DC Motor


Circuit Diagram:
Code:
int potPin = A0;

int buttonPin = 7;

int forward1 = 5;

int forward2 = 4;

int backward1 = 3;

int backward2 = 2;

int potValue = 0;

int motorValue = 0;

int buttonState = 0;

boolean a;

void setup()

pinMode(buttonPin, INPUT_PULLUP);

pinMode (forward1, OUTPUT);

pinMode (forward2, OUTPUT);

pinMode (backward1, OUTPUT);

pinMode (backward2, OUTPUT);

void loop()

potValue = analogRead(potPin);
motorValue = map(potValue, 0, 1023, 0, 255);

buttonState = digitalRead(buttonPin);

if (buttonState == LOW)

a=!a;

if(a)

analogWrite(backward1, motorValue);

digitalWrite (backward2, HIGH);

digitalWrite (forward1, LOW);

digitalWrite (forward2, LOW);

else

analogWrite(forward1, motorValue);

digitalWrite (forward2, HIGH);

digitalWrite (backward1, LOW);

digitalWrite (backward2, LOW);

}
Experiment 11 & 12
Task:
Design basic calculator using switches and LEDs (use only addition, subtraction, multiplication
and division).

Parts Required:
The parts required for this task are

➢ Arduino Uno
➢ Breadboard
➢ Jumper Wires
➢ Keypad (4x4)
➢ Standard LCD Display (16x2)

1) Arduino Uno:
The Arduino Uno is an open-source microcontroller board based on the Microchip
ATmega328P microcontroller and developed by Arduino.cc and initially released in 2010. The
board is equipped with sets of digital and analog input/output (I/O) pins that may be interfaced to
various expansion boards (shields) and other circuits.

The board has 14 digital I/O pins (six capable of PWM output), 6 analog I/O pins, and is
programmable with the Arduino IDE (Integrated Development Environment), via a type B USB
cable. It can be powered by the USB cable or by an external 9-volt battery, though it accepts
voltages between 7 and 20 volts. It is similar to the Arduino Nano and Leonardo.

The major components of Arduino UNO board are as follows:

➢ USB Connector: This is a printer USB port used to load a program from the Arduino IDE onto
the Arduino board. The board can also be powered through this port.
➢ Power Port: The Arduino board can be powered through an AC-to-DC adapter or a battery. The
power source can be connected by plugging in a 2.1mm center-positive plug into the power jack of
the board.
➢ Microcontroller: It is the most prominent black rectangular chip with 28 pins. Think of it as the
brains of your Arduino. The microcontroller used on the UNO board is Atmega328P by Atmel.
Atmega328P has the following components in it:

❖ Flash memory of 32KB. The program loaded from Arduino IDE is stored here.
❖ RAM of 2KB. This is a runtime memory.
❖ CPU: It controls everything that goes on within the device. It fetches the program
instructions from flash memory and runs them with the help of RAM.
❖ Electrically Erasable Programmable Read Only Memory (EEPROM) of 1KB.
This is a type of non-volatile memory, and it keeps the data even after device restart
and reset.

➢ Analog Input Pins: The Arduino UNO board has 6 analog input pins, labeled “Analog 0 to 5.”
These pins can read the signal from an analog sensor like a temperature sensor and convert it into
a digital value so that the system understands. These pins just measure voltage and not the current
because they have very high internal resistance.
➢ Digital Pins: You can find these pins labeled “Digital 0 to 13.” These pins can be used as either
input or output pins. When used as output, these pins act as a power supply source but when used
as input pins, they read the signals from the component connected to them.
➢ Reset Switch: When this switch is clicked, it sends a logical pulse to the reset pin of the
Microcontroller, and now runs the program again from the start.
➢ Crystal Oscillator: This is a quartz crystal oscillator which ticks 16 million times a second. On
each tick, the microcontroller performs one operation, for example, addition, subtraction, etc.
➢ USB Interface Chip: Think of this as a signal translator. It converts signals in the USB level to
a level that an Arduino UNO board understands.
➢ TX RX LEDs: TX stands for transmit, and RX for receive. These are indicator LEDs which blink
whenever the UNO board is transmitting or receiving data.

Fig 01: Arduino Uno


Arduino IDE:
The Arduino IDE is an open-source software, which is used to write and upload code to
the Arduino boards. The IDE application is suitable for different operating systems such as
Windows, Mac OS X, and Linux. It supports the programming languages C and C++. Here, IDE
stands for Integrated Development Environment.

The program or code written in the Arduino IDE is often called as sketching. We need to
connect the Genuino and Arduino board with the IDE to upload the sketch written in the Arduino
IDE software. The sketch is saved with the extension '.ino'.

The Arduino IDE will appear as:

Fig 02: Arduino IDE


2) Breadboard:
A breadboard is a widely used tool to design and test circuit. You do not need to solder
wires and components to make a circuit while using a bread board. It is easier to mount components
& reuse them. Since, components are not soldered you can change your circuit design at any point
without any hassle. It consists of an array of conductive metal clips encased in a box made of white
ABS plastic, where each clip is insulated with another clips.

There are a number of holes on the plastic box, arranged in a particular fashion. A typical
bread board layout consists of two types of regions also called strips. Bus strips and socket strips.

Bus strips are usually used to provide power supply to the circuit. It consists of two
columns, one for power voltage and other for ground.

Socket strips are used to hold most of the components in a circuit. Generally, it consists of
two sections each with 5 rows and 64 columns. Every column is electrically connected from inside.

Fig 03: Breadboard

3) Jumper Wires:
Jumper wires are simply wires that have connector pins at each end, allowing them to be
used to connect two points to each other without soldering. Jumper wires are typically used with
breadboards and other prototyping tools in order to make it easy to change a circuit as needed.
Fairly simple. In fact, it doesn’t get much more basic than jumper wires.

Jumper wires typically come in three versions:

➢ male-to-male
➢ male-to-female
➢ female-to-female
The difference between each is in the end point of the wire. Male ends have a pin protruding
and can plug into things, while female ends do not and are used to plug things into. Male-to-male
jumper wires are the most common and what you likely will use most often. When connecting two
ports on a breadboard, a male-to-male wire is what you’ll need.

Fig 04: Jumper Wires

4) Standard LCD Display:


An LCD (Liquid Crystal Display) screen is an electronic display module and has a wide range
of applications. A 16x2 LCD display is very basic module and is very commonly used in various
devices and circuits. 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 5x7 pixel matrix. The 16 x 2 intelligent alphanumeric
dot matrix display is capable of displaying 224 different characters and symbols. This LCD has
two registers, namely, Command and Data.

Command registers stores various commands given to the display. Data register stores data to
be displayed. The process of controlling the display involves putting the data that form the image
of what you want to display into the data registers, then putting instructions in the instruction
register. In your Arduino project Liquid Crystal Library simplifies this for you so you don't need
to know the low-level instructions. Contrast of the display can be adjusted by adjusting the
potentiometer to be connected across VEE pin.
Fig 05: 16x2 LCD Display

5) Keypad:
Keypad is used as an input device to read the key pressed by the user and to process it. 4x4
keypad consists of 4 rows and 4 columns. Switches are placed between the rows and columns. A
key press establishes a connection between the corresponding row and column, between which the
switch is placed.

Fig 06: 4x4 Keypad


As given in above table, a 4x4 keypad will have eight terminals. In them four are rows of
matrix and four are columns of matrix. These 8 pins are driven out from 16 buttons present in the
module. Those 16 alphanumeric digits on the module surface are the 16 buttons arranged in matrix
formation. The internal structure of 4x4 keypad module is shown below.
Circuit Diagram:

Performance Diagram:
Code:
#include <Keypad.h>

#include <LiquidCrystal.h>

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

const int LCD_COLS = 16;

const int LCD_ROWS = 2;

double num1,num2 ;

double total;

char operation,button;

const byte ROWS = 4;

const byte COLS = 4;

char keys[ROWS][COLS] = {

{'1','2','3','+'},

{'4','5','6','-'},

{'7','8','9','*'},

{'=','0','%','/'}

};

byte rowPins[ROWS] = { A2, A3, A4, A5};

byte colPins[COLS] = { 2, 3, 4, 5};


Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS ); // Create the
Keypad

void domath() // Simple switch case to pick what operation to do, based on button pressed by user.

switch(operation)

case '+': // Addition

total = num1+num2;

break;

case '-': // Subtraction

total = num1-num2;

break;

case '/': // Division.

total = num1/num2;

break;

case '*': // Multiplication

total = num1*num2;

break;

case '%': // Modulus

total = (int)num1%(int)num2;

break;

lcd.setCursor(0,1);
lcd.print('=');

lcd.setCursor(1,1);

lcd.print(total);

void setup() {

int status = lcd.begin(LCD_COLS, LCD_ROWS);

if(status)

status = -status; // convert negative status value to positive number

hd44780::fatalError(status); // does not return

lcd.print("Calculator");

void loop()

while(1)

button = kpd.getKey();

if (button >='0' && button <='9')

lcd.clear();
num1 = num1*10 + (button -'0');

lcd.setCursor(0,0);

lcd.print(num1);

//Inputting operator

if (num1 !=0 && (button=='+' || button=='-' || button=='*' || button=='/' || button=='%'))

operation = button;

lcd.setCursor(0,1);

lcd.print(operation);

break;

while(1)

button = kpd.getKey();

if (button >='0' && button <='9')

num2 = num2*10 + (button -'0');

lcd.setCursor(1,1);

lcd.print(num2);

}
if (button == '=' && num2 !=0) //Do calculation if '=' is pressed

domath();

break;

while(1)

button = kpd.getKey();

if (button =='=')

lcd.clear();

lcd.setCursor(0,0);

num1=0;

num2=0;

total=0;

operation=0;

break;

}
Experiment 13 & 14
Task:
Design home energy saving system with autonomous techniques using sensors. (Autonomous
switching of lights). Design a smart home on hard board.

Parts Required:
The parts required for this task are

➢ Arduino Uno
➢ Breadboard
➢ Jumper Wires
➢ Light Sensor
➢ Resistor
➢ LED
➢ Ultrasonic Sensor

1) Arduino Uno:
The Arduino Uno is an open-source microcontroller board based on the Microchip
ATmega328P microcontroller and developed by Arduino.cc and initially released in 2010. The
board is equipped with sets of digital and analog input/output (I/O) pins that may be interfaced to
various expansion boards (shields) and other circuits.

The board has 14 digital I/O pins (six capable of PWM output), 6 analog I/O pins, and is
programmable with the Arduino IDE (Integrated Development Environment), via a type B USB
cable. It can be powered by the USB cable or by an external 9-volt battery, though it accepts
voltages between 7 and 20 volts. It is similar to the Arduino Nano and Leonardo.

The major components of Arduino UNO board are as follows:

➢ USB Connector: This is a printer USB port used to load a program from the Arduino IDE onto
the Arduino board. The board can also be powered through this port.
➢ Power Port: The Arduino board can be powered through an AC-to-DC adapter or a battery. The
power source can be connected by plugging in a 2.1mm center-positive plug into the power jack of
the board.
➢ Microcontroller: It is the most prominent black rectangular chip with 28 pins. Think of it as the
brains of your Arduino. The microcontroller used on the UNO board is Atmega328P by Atmel.
Atmega328P has the following components in it:

❖ Flash memory of 32KB. The program loaded from Arduino IDE is stored here.
❖ RAM of 2KB. This is a runtime memory.
❖ CPU: It controls everything that goes on within the device. It fetches the program
instructions from flash memory and runs them with the help of RAM.
❖ Electrically Erasable Programmable Read Only Memory (EEPROM) of 1KB.
This is a type of non-volatile memory, and it keeps the data even after device restart
and reset.

➢ Analog Input Pins: The Arduino UNO board has 6 analog input pins, labeled “Analog 0 to 5.”
These pins can read the signal from an analog sensor like a temperature sensor and convert it into
a digital value so that the system understands. These pins just measure voltage and not the current
because they have very high internal resistance.
➢ Digital Pins: You can find these pins labeled “Digital 0 to 13.” These pins can be used as either
input or output pins. When used as output, these pins act as a power supply source but when used
as input pins, they read the signals from the component connected to them.
➢ Reset Switch: When this switch is clicked, it sends a logical pulse to the reset pin of the
Microcontroller, and now runs the program again from the start.
➢ Crystal Oscillator: This is a quartz crystal oscillator which ticks 16 million times a second. On
each tick, the microcontroller performs one operation, for example, addition, subtraction, etc.
➢ USB Interface Chip: Think of this as a signal translator. It converts signals in the USB level to
a level that an Arduino UNO board understands.
➢ TX RX LEDs: TX stands for transmit, and RX for receive. These are indicator LEDs which blink
whenever the UNO board is transmitting or receiving data.

Fig 01: Arduino Uno


Arduino IDE:
The Arduino IDE is an open-source software, which is used to write and upload code to
the Arduino boards. The IDE application is suitable for different operating systems such as
Windows, Mac OS X, and Linux. It supports the programming languages C and C++. Here, IDE
stands for Integrated Development Environment.

The program or code written in the Arduino IDE is often called as sketching. We need to
connect the Genuino and Arduino board with the IDE to upload the sketch written in the Arduino
IDE software. The sketch is saved with the extension '.ino'.

The Arduino IDE will appear as:

Fig 02: Arduino IDE


2) Breadboard:
A breadboard is a widely used tool to design and test circuit. You do not need to solder
wires and components to make a circuit while using a bread board. It is easier to mount components
& reuse them. Since, components are not soldered you can change your circuit design at any point
without any hassle. It consists of an array of conductive metal clips encased in a box made of white
ABS plastic, where each clip is insulated with another clips.

There are a number of holes on the plastic box, arranged in a particular fashion. A typical
bread board layout consists of two types of regions also called strips. Bus strips and socket strips.

Bus strips are usually used to provide power supply to the circuit. It consists of two
columns, one for power voltage and other for ground.

Socket strips are used to hold most of the components in a circuit. Generally, it consists of
two sections each with 5 rows and 64 columns. Every column is electrically connected from inside.

Fig 03: Breadboard

3) Jumper Wires:
Jumper wires are simply wires that have connector pins at each end, allowing them to be
used to connect two points to each other without soldering. Jumper wires are typically used with
breadboards and other prototyping tools in order to make it easy to change a circuit as needed.
Fairly simple. In fact, it doesn’t get much more basic than jumper wires.

Jumper wires typically come in three versions:

➢ male-to-male
➢ male-to-female
➢ female-to-female
The difference between each is in the end point of the wire. Male ends have a pin protruding
and can plug into things, while female ends do not and are used to plug things into. Male-to-male
jumper wires are the most common and what you likely will use most often. When connecting two
ports on a breadboard, a male-to-male wire is what you’ll need.

Fig 04: Jumper Wires

4) Light Sensor:
A Light Sensor generates an output signal indicating the intensity of light by measuring the
radiant energy that exists in a very narrow range of frequencies basically called “light”, and which
ranges in frequency from “Infra-red” to “Visible” up to “Ultraviolet” light spectrum.

The light sensor is a passive device that convert this “light energy” whether visible or in the
infra-red parts of the spectrum into an electrical signal output. Light sensors are more commonly
known as “Photoelectric Devices” or “Photo Sensors” because the convert light energy (photons)
into electricity (electrons).

Fig 07: Light Sensor


5) Resistor:
Resistor is defined as

“A passive electrical component with two terminals that are used for either limiting or
regulating the flow of electric current in electrical circuits.”

The main purpose of resistor is to reduce the current flow and to lower the voltage in any
particular portion of the circuit. It is made of copper wires which are coiled around a ceramic rod
and the outer part of the resistor is coated with an insulating paint. The SI unit of resistor is Ohm.

Fig 06: Resistor

6) LED:
A light-emitting diode (LED) is a semiconductor device that emits light when an electric
current flows through it. When current passes through an LED, the electrons recombine with holes
emitting light in the process. LEDs allow the current to flow in the forward direction and blocks
the current in the reverse direction.

Fig 05: LED (Light Emitting Diode)

Light-emitting diodes are heavily doped p-n junctions. Based on the semiconductor material
used and the amount of doping, an LED will emit colored light at a particular spectral wavelength
when forward biased. As shown in the figure, an LED is encapsulated with a transparent cover so
that emitted light can come out.

The color of an LED is determined by the material used in the semiconducting element. The
two primary materials used in LEDs are aluminum gallium indium phosphide alloys and indium
gallium nitride alloys. Aluminum alloys are used to obtain red, orange and yellow light, and indium
alloys are used to get green, blue and white light. Slight changes in the composition of these alloys
change the color of the emitted light.

Light-emitting diode (LED) is a widely used standard source of light in electrical equipment.
It has a wide range of applications ranging from your mobile phone to large advertising billboards.
They mostly find applications in devices that show the time and display different types of data.

7) Ultrasonic Sensor:
Ultrasonic sensors are electronic devices that calculate the target’s distance by emission of
ultrasonic sound waves and convert those waves into electrical signals. The speed of emitted
ultrasonic waves traveling speed is faster than the audible sound.

Fig 05: Ultrasonic Sensor

To know the distance between the target and the sensor, the sensor calculates the amount of
time required for sound emission to travel from transmitter to receiver. The calculation is done as
follows:

D = 1/2 * T * C

Ultrasonic Sensor Pin Diagram:


The ultrasonic sensor pin diagram is:

VCC – This pin has to be connected to a power supply +5V.

TRIG – This pin is used to receive controlling signals from the Arduino board. This is the
triggering input pin of the sensor
ECHO – This pin is used for sending signals to the Arduino board where the Arduino calculates
the pulse duration to know the distance. This pin is the ECHO output of the sensor.

GND – This pin has to be connected to the ground.

Theory:
Now a days, the street lights we are using are not smart. To make them more smart here is a project
that glows LED automatically when a vehicle is moving on road during night. Today this project
will help you to develop a small prototype using Arduino Uno, ultrasonic sensor and LDR.

Hence we, decided to come up with the Smart Street Lights system. It's essentially a setup which
uses the popular Ultrasonic Sensor(HC-SR04), LDR and Arduino Uno. Hence the power
consumed for street lights can be minimized.

Working Principle:
The working principle is very simple. The Arduino Uno continuously checks for the
communication from ultrasonic sensor and LDR. The led will be ON when the light intensity and
the distance from ultrasonic sensor are satisfied. Otherwise, the led will be in OFF position. This
is the working principle of Smart Street Lights with LDR and ultrasonic sensor. So that we can
minimize the power usage of street lights.

Circuit Diagram:
Code:
const int trigpin=9;

const int echopin=10;

const int ledpin=13;

const int ldrpin=A0;

long duration;

int distance;

int safedistance;

void setup() {

pinMode(trigpin,OUTPUT);

pinMode(echopin,INPUT);

pinMode(ledpin,OUTPUT);

pinMode(ldrpin,INPUT);

void loop() {

Serial.begin(9600);

digitalWrite(trigpin,LOW);

delayMicroseconds(2);

digitalWrite(trigpin,HIGH);

delayMicroseconds(10);

digitalWrite(trigpin,LOW);

duration=pulseIn(echopin,HIGH);
distance=duration*0.034/2;

safedistance=distance;

int light=analogRead(ldrpin);

if(light<=400){

if(safedistance<=5){

digitalWrite(ledpin,HIGH);

delay(10);

else if(safedistance>5){

digitalWrite(ledpin,LOW);

delay(10);

delay(200);

}
Experiment 13 & 14
Task:
Design home energy saving system with autonomous techniques using sensors. (Autonomous
switching of lights). Design a smart home on hard board.

Parts Required:
The parts required for this task are

➢ Arduino Uno
➢ Breadboard
➢ Jumper Wires
➢ Ultrasonic Sensor
➢ LCD - 16x2
➢ Relay
➢ Texas Instruments BOOSTXL-ULN2003 ULN2003A Dual Stepper
➢ Motor Booster Pack
➢ 9-volt battery

1) Arduino Uno:
The Arduino Uno is an open-source microcontroller board based on the Microchip
ATmega328P microcontroller and developed by Arduino.cc and initially released in 2010. The
board is equipped with sets of digital and analog input/output (I/O) pins that may be interfaced to
various expansion boards (shields) and other circuits.

The board has 14 digital I/O pins (six capable of PWM output), 6 analog I/O pins, and is
programmable with the Arduino IDE (Integrated Development Environment), via a type B USB
cable. It can be powered by the USB cable or by an external 9-volt battery, though it accepts
voltages between 7 and 20 volts. It is similar to the Arduino Nano and Leonardo.

The major components of Arduino UNO board are as follows:

➢ USB Connector: This is a printer USB port used to load a program from the Arduino IDE onto
the Arduino board. The board can also be powered through this port.
➢ Power Port: The Arduino board can be powered through an AC-to-DC adapter or a battery. The
power source can be connected by plugging in a 2.1mm center-positive plug into the power jack of
the board.
➢ Microcontroller: It is the most prominent black rectangular chip with 28 pins. Think of it as the
brains of your Arduino. The microcontroller used on the UNO board is Atmega328P by Atmel.
Atmega328P has the following components in it:
❖ Flash memory of 32KB. The program loaded from Arduino IDE is stored here.
❖ RAM of 2KB. This is a runtime memory.
❖ CPU: It controls everything that goes on within the device. It fetches the program
instructions from flash memory and runs them with the help of RAM.
❖ Electrically Erasable Programmable Read Only Memory (EEPROM) of 1KB.
This is a type of non-volatile memory, and it keeps the data even after device restart
and reset.

➢ Analog Input Pins: The Arduino UNO board has 6 analog input pins, labeled “Analog 0 to 5.”
These pins can read the signal from an analog sensor like a temperature sensor and convert it into
a digital value so that the system understands. These pins just measure voltage and not the current
because they have very high internal resistance.
➢ Digital Pins: You can find these pins labeled “Digital 0 to 13.” These pins can be used as either
input or output pins. When used as output, these pins act as a power supply source but when used
as input pins, they read the signals from the component connected to them.
➢ Reset Switch: When this switch is clicked, it sends a logical pulse to the reset pin of the
Microcontroller, and now runs the program again from the start.
➢ Crystal Oscillator: This is a quartz crystal oscillator which ticks 16 million times a second. On
each tick, the microcontroller performs one operation, for example, addition, subtraction, etc.
➢ USB Interface Chip: Think of this as a signal translator. It converts signals in the USB level to
a level that an Arduino UNO board understands.
➢ TX RX LEDs: TX stands for transmit, and RX for receive. These are indicator LEDs which blink
whenever the UNO board is transmitting or receiving data.

Fig 01: Arduino Uno


Arduino IDE:
The Arduino IDE is an open-source software, which is used to write and upload code to
the Arduino boards. The IDE application is suitable for different operating systems such as
Windows, Mac OS X, and Linux. It supports the programming languages C and C++. Here, IDE
stands for Integrated Development Environment.

The program or code written in the Arduino IDE is often called as sketching. We need to
connect the Genuino and Arduino board with the IDE to upload the sketch written in the Arduino
IDE software. The sketch is saved with the extension '.ino'.

The Arduino IDE will appear as:

Fig 02: Arduino IDE


2) Breadboard:
A breadboard is a widely used tool to design and test circuit. You do not need to solder
wires and components to make a circuit while using a bread board. It is easier to mount components
& reuse them. Since, components are not soldered you can change your circuit design at any point
without any hassle. It consists of an array of conductive metal clips encased in a box made of white
ABS plastic, where each clip is insulated with another clips.

There are a number of holes on the plastic box, arranged in a particular fashion. A typical
bread board layout consists of two types of regions also called strips. Bus strips and socket strips.

Bus strips are usually used to provide power supply to the circuit. It consists of two
columns, one for power voltage and other for ground.

Socket strips are used to hold most of the components in a circuit. Generally, it consists of
two sections each with 5 rows and 64 columns. Every column is electrically connected from inside.

Fig 03: Breadboard

3) Jumper Wires:
Jumper wires are simply wires that have connector pins at each end, allowing them to be
used to connect two points to each other without soldering. Jumper wires are typically used with
breadboards and other prototyping tools in order to make it easy to change a circuit as needed.
Fairly simple. In fact, it doesn’t get much more basic than jumper wires.

Jumper wires typically come in three versions:

➢ male-to-male
➢ male-to-female
➢ female-to-female
The difference between each is in the end point of the wire. Male ends have a pin protruding
and can plug into things, while female ends do not and are used to plug things into. Male-to-male
jumper wires are the most common and what you likely will use most often. When connecting two
ports on a breadboard, a male-to-male wire is what you’ll need.

Fig 04: Jumper Wires

4) Ultrasonic Sensor:
Ultrasonic sensors are electronic devices that calculate the target’s distance by emission of
ultrasonic sound waves and convert those waves into electrical signals. The speed of emitted
ultrasonic waves traveling speed is faster than the audible sound.

Fig 05: Ultrasonic Sensor

To know the distance between the target and the sensor, the sensor calculates the amount of
time required for sound emission to travel from transmitter to receiver. The calculation is done as
follows:
D = 1/2 * T * C

Ultrasonic Sensor Pin Diagram:


The ultrasonic sensor pin diagram is:

VCC – This pin has to be connected to a power supply +5V.

TRIG – This pin is used to receive controlling signals from the Arduino board. This is the
triggering input pin of the sensor

ECHO – This pin is used for sending signals to the Arduino board where the Arduino calculates
the pulse duration to know the distance. This pin is the ECHO output of the sensor.

GND – This pin has to be connected to the ground.

5) LCD – 16x2:
An LCD (Liquid Crystal Display) screen is an electronic display module and has a wide range
of applications. A 16x2 LCD display is very basic module and is very commonly used in various
devices and circuits. 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 5x7 pixel matrix. The 16 x 2 intelligent alphanumeric
dot matrix display is capable of displaying 224 different characters and symbols. This LCD has
two registers, namely, Command and Data.

The process of controlling the display involves putting the data that form the image of what
you want to display into the data registers, then putting instructions in the instruction register

Fig 06: 16x2 LCD Display


6) Relay Module:
A power relay module is an electrical switch that is operated by an electromagnet. The
electromagnet is activated by a separate low-power signal from a micro controller. When activated,
the electromagnet pulls to either open or close an electrical circuit.

A simple relay consists of wire coil wrapped around a soft iron core, or solenoid, an iron
yoke that delivers a low reluctance path for magnetic flux, a movable iron armature and one or
more sets of contacts. The movable armature is hinged to the yoke and linked to one or more set
of the moving contacts.

Fig 07: Relay Module

7) Texas Instruments BOOSTXL-ULN2003 ULN2003A Dual Stepper:


The BOOSTXL-ULN2003 is 2A stepper motor driver kit which features TI's ULN2003A
bipolar transistor array and the CSD1751Q2 NexFET™. This BoosterPack™ contains everything
needed to drive up to 2 stepper motors or 8 channels, with up to 30V and supports both serial and
parallel interfaces.

This design features the SN74HC595 shift register to enable serial communication to
reduce the number of GPIOs used. The switches on-board also enable parallel interface to directly
control each channel for Motor 1 or Motor 2.

Fig 08: Texas Instruments BOOSTXL-ULN2003 ULN2003A Dual Stepper


8) 9V Battery:
The 9V battery is an extremely common battery that was first used in transistor radios. It
features a rectangular prism shape that utilizes a pair of snap connectors which are located at the
top of the battery. A wide array of both large and small battery manufacturers produces versions
of the 9V battery.

Possible chemistries of primary (non-rechargeable) 9V batteries include Alkaline, Carbon-


Zinc (Heavy Duty), Lithium. Possible chemistries of secondary (rechargeable) 9V batteries include
nickel-cadmium (NiCd ), nickel-metal hydride (NiMH ), and lithium ion. The performance and
application of the battery can vary greatly between different chemistries, meaning that some
chemistiries are better suited for some applications over others.

Fig 09: 9V Battery


Circuit Diagram:

Code:
#include <LiquidCrystal.h>

#define trigger 10

#define echo 11

#define motor 8

#define buzzer 12

LiquidCrystal lcd(7,6,5,4,3,2);

float time=0,distance=0;

int temp=0;

void setup(){

lcd.begin(16,2);
pinMode(trigger,OUTPUT);

pinMode(echo,INPUT);

pinMode(motor, OUTPUT);

pinMode(buzzer, OUTPUT);

lcd.print(" Water Level ");

lcd.setCursor(0,1);

lcd.print(" Indicator ");

delay(2000);

void loop(){

lcd.clear();

digitalWrite(trigger,LOW);

delayMicroseconds(2);

digitalWrite(trigger,HIGH);

delayMicroseconds(10);

digitalWrite(trigger,LOW);

delayMicroseconds(2);

time=pulseIn(echo,HIGH);

distance=time*340/20000;

lcd.clear();

lcd.print("Water Space In ");

lcd.setCursor(0,1);

lcd.print("Tank is: ");

lcd.print(distance);
lcd.print("Cm");

delay(2000);

if(distance<12 && temp==0) {

digitalWrite(motor, LOW);

digitalWrite(buzzer, HIGH);

lcd.clear();

lcd.print("Water Tank Full ");

lcd.setCursor(0,1);

lcd.print("Motor Turned OFF");

delay(2000);

digitalWrite(buzzer, LOW);

delay(3000);

temp=1;

else if(distance<12 && temp==1) {

digitalWrite(motor, LOW);

lcd.clear();

lcd.print("Water Tank Full ");

lcd.setCursor(0,1);

lcd.print("Motor Turned OFF");

delay(5000);

}
else if(distance>30) {

digitalWrite(motor, HIGH);

lcd.clear();

lcd.print("LOW Water Level");

lcd.setCursor(0,1);

lcd.print("Motor Turned ON");

delay(5000);

temp=0;

You might also like