Precision Engineering Lab Manuals
Precision Engineering Lab Manuals
Lab Manuals
Submitted By
Name: Abuhoraira Khalil
Reg No: MEEN201101003
Submitted To
Engr Syed Saad Farooq
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
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.
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.
➢ 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.
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'.
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.
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.
➢ 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.
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.
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.
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.
➢ 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.
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'.
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.
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.
➢ 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.
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.
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.
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.
➢ 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.
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'.
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.
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.
➢ 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.
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.
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.
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.
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.
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);
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.
➢ 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.
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'.
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.
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.
➢ 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.
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.
D = 1/2 * T * C
Where,
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.
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 duration;
int distance;
void setup(){
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(buzzPin, OUTPUT);
void loop(){
digitalWrite(trigPin, HIGH);
delay(8);
digitalWrite(trigPin, LOW);
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.
➢ 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.
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'.
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.
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.
➢ 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.
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.
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.
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 msvalue;
void setup() {
pinMode(msensor, INPUT);
pinMode(led, OUTPUT);
void loop() {
msvalue = analogRead(msensor);
digitalWrite(led, HIGH);
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.
➢ 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.
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'.
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.
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.
➢ 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.
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.
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.
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>
int position = 0;
char keys[ROWS][COLS] =
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
byte colPins[COLS] = { 5, 4, 3, 2 };
void setup() {
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
digitalWrite(green, LOW);
digitalWrite(red, HIGH);
void loop()
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.
➢ 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.
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'.
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.
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.
➢ 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.
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.
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.
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).
Performance Diagram:
Code:
int ledPin = 13;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(ldrPin, INPUT);
void loop() {
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.
➢ 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.
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'.
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.
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.
➢ 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.
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.
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.
Performance Diagram:
Code:
#include <LiquidCrystal.h>
void setup()
lcd.begin(16,2);
void loop()
lcd.setCursor(0,1);
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.
➢ 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.
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'.
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.
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.
➢ 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.
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.
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.
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.
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.
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.
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);
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);
else
analogWrite(forward1, motorValue);
}
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.
➢ 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.
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'.
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.
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.
➢ 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.
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.
Performance Diagram:
Code:
#include <Keypad.h>
#include <LiquidCrystal.h>
double num1,num2 ;
double total;
char operation,button;
char keys[ROWS][COLS] = {
{'1','2','3','+'},
{'4','5','6','-'},
{'7','8','9','*'},
{'=','0','%','/'}
};
void domath() // Simple switch case to pick what operation to do, based on button pressed by user.
switch(operation)
total = num1+num2;
break;
total = num1-num2;
break;
total = num1/num2;
break;
total = num1*num2;
break;
total = (int)num1%(int)num2;
break;
lcd.setCursor(0,1);
lcd.print('=');
lcd.setCursor(1,1);
lcd.print(total);
void setup() {
if(status)
lcd.print("Calculator");
void loop()
while(1)
button = kpd.getKey();
lcd.clear();
num1 = num1*10 + (button -'0');
lcd.setCursor(0,0);
lcd.print(num1);
//Inputting operator
operation = button;
lcd.setCursor(0,1);
lcd.print(operation);
break;
while(1)
button = kpd.getKey();
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.
➢ 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.
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'.
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.
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.
➢ 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.
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).
“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.
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.
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.
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
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.
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;
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.
➢ 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.
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'.
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.
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.
➢ 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.
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.
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
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.
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
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.
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.
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.setCursor(0,1);
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.setCursor(0,1);
lcd.print(distance);
lcd.print("Cm");
delay(2000);
digitalWrite(motor, LOW);
digitalWrite(buzzer, HIGH);
lcd.clear();
lcd.setCursor(0,1);
delay(2000);
digitalWrite(buzzer, LOW);
delay(3000);
temp=1;
digitalWrite(motor, LOW);
lcd.clear();
lcd.setCursor(0,1);
delay(5000);
}
else if(distance>30) {
digitalWrite(motor, HIGH);
lcd.clear();
lcd.setCursor(0,1);
delay(5000);
temp=0;