SlideShare a Scribd company logo
www.karkhana.club
1Make Things with Arduino – Karkhana Makerspace©
By Siddharth Bhatter & Akash Verma
This manual is the Intellectual property of Karkhana Makerspace. It must only
be published in its origianl form. Using parts or republishing altered parts of
this guide is prohibited without permission from Karkhana Makerspace
www.karkhana.club
2Make Things with Arduino – Karkhana Makerspace©
CHAPTER - 1
BASIC ELECTRONICS
www.karkhana.club
3Make Things with Arduino – Karkhana Makerspace©
1. Basic Electronics
Getting started with basic electronics is easier than you
think.This instructable will hopefully demystify the
basics of electronics so that anyone with an interest in
building circuits can hit the ground running. This is a
quick overview into practical electronics and it is not
my goal to delve deeply into the science of electrical
engineering. If you are interested in learning more
about the science of basic electronics, Wikipedia is a
good place to start your search.
By the end of this Instructable, anyone with an interest
to learn basic electronics should be able to read a
schematic and build a circuit using standard electronic
components.
www.karkhana.club
4Make Things with Arduino – Karkhana Makerspace©
1.1 Electricity
www.karkhana.club
5Make Things with Arduino – Karkhana Makerspace©
There are two types of electrical signals :-
a) Alternating Current (AC)
Fig 1. Circuit
Diagram with
AC Source
Fig 2.
Waveform of
AC signal
With alternating current, the direction electricity flows
throughout the circuit is constantly reversing. You may
even say that it is alternating direction. The rate of
www.karkhana.club
6Make Things with Arduino – Karkhana Makerspace©
reversal is measured in Hertz, which is the number of
reversals per second. So, when they say that the US
power supply is 60 Hz, what they mean is that it is
reversing 120 times per second (twice per cycle).
b) Direct Current (DC)
Waveform of DC signal
Fig3.Circuit diagram
with DC source
www.karkhana.club
7Make Things with Arduino – Karkhana Makerspace©
With Direct Current, electricity flows in one direction
between power and ground. In this arrangement there
is always a positive source of voltage and ground
(0volt) source of voltage.
1.2 Circuit
A circuit is a complete and closed path through which
electric current can flow. In other words, a closed
circuit would allow the flow of electricity between
power and ground. An open circuit would break the
flow of electricity between power and ground.
Circuit
www.karkhana.club
8Make Things with Arduino – Karkhana Makerspace©
Anything that is part of this closed system and that
allows electricity to flow between power and ground is
considered to be part of the circuit.
1.3 Resistance
In the circuit above, the motor that electricity is flowing
through is adding resistance to the flow of electricity.
Thus, all of the electricity passing through the circuit is
being put to use.
In other words, there needs to be something wired
between positive and ground that adds resistance to
the flow of electricity and uses it up. If positive voltage
is connected directly to ground and does not first pass
through something that adds resistance, like a motor,
Resistance
www.karkhana.club
9Make Things with Arduino – Karkhana Makerspace©
this will result in a short circuit. This means that the
positive voltage is connected directly to ground.
Likewise, if electricity passes through a component (or
group of components) that does not add enough
resistance to the circuit, a short will likewise occur.
Shorts are bad because they will result in your battery
and/or circuit overheating, breaking, catching on fire,
and/or exploding.
It is very important to prevent short circuits by making
sure that the positive voltage is never wired directly to
ground.
www.karkhana.club
10Make Things with Arduino – Karkhana Makerspace©
1.4 Series Vs. Parallel
Series and Parallel Circuits
There are two different ways in which you can wire
things together called series and parallel.
When things are wired in series, things are wired one
after another, such that electricity has to pass through
one thing, then the next thing, then the next, and so
on.
When things are wired in parallel, they are wired side
by side, such that electricity passes through all of them
at the same time, from one common point to another
common point.
www.karkhana.club
11Make Things with Arduino – Karkhana Makerspace©
1.5 Basic Components
In order to build circuits, you will need to become
familiar with a few basic components. These
components may seem simple, but are the bread and
butter of most electronics projects. Thus, by learning
about these few basic parts, you will be able to go a
long way.Bear with me as I elaborate as to what each
of these are in the coming steps.
www.karkhana.club
12Make Things with Arduino – Karkhana Makerspace©
1.6 Resistors
As the name implies, resistors add resistance to the
circuit and reduces the flow of electrical current. It is
represented in a circuit diagram as a pointy squiggle
with a value next to it.
The different markings on the resistor represent
different values of resistance. These values are
measured in ohms.
You read the values from left to right towards the
(typically) gold band. The first two colors represent the
resistor value, the third represents the multiplier, and
www.karkhana.club
13Make Things with Arduino – Karkhana Makerspace©
the fourth (the gold band) represents the tolerance or
precision of the component. You can tell the value of
each color by looking at a resistor color value chart.
Or... to make your life easier, you
could simply look up the values using a graphical
resistance calculator.
Anyhow... a resistor with the
markings brown, black, orange, gold will translate as
follows:
1 (brown) 0 (black) x 1,000 = 10,000 with a tolerance of
+/- 5% Any resistor of over 1000 ohms is typically
shorted using the letter K. For instance, 1,000 would be
1K; 3,900, would translate to 3.9K; and 470,000 ohms
would become 470K.Values of ohms over a million are
represented using the letter M. In this case, 1,000,000
ohms would become 1M.
www.karkhana.club
14Make Things with Arduino – Karkhana Makerspace©
1.7 Capacitors
A capacitor is a component that stores electricity and
then discharges it into the circuit when there is a drop
in electricity. You can think of it as a water storage tank
that releases water when there is a drought to ensure a
steady stream.
Capacitors are measured in Farads. The values that you
will typically encounter in most capacitors are
measured in picofarad (pF), nanofarad (nF), and
microfarad (uF).
www.karkhana.club
15Make Things with Arduino – Karkhana Makerspace©
Types of capacitor :-
a) Electrolytic Capacitors
 Electrolytic capacitors are typically polarized.
 One leg needs to be connected to the ground
side of the circuit and the other leg must be
connected to power.
 Electrolytic capacitors have the value written
on them,typically represented in uF.
 They also mark the leg which connects to
ground with a minus symbol (-).
www.karkhana.club
16Make Things with Arduino – Karkhana Makerspace©
i) Ceramic Disc Capacitors
 Ceramic disc capacitors are non-polarized.
 Electricity can pass through them no matter
how they are inserted in the circuit.
 They are typically marked with a number code
which needs to be decoded.
www.karkhana.club
17Make Things with Arduino – Karkhana Makerspace©
Step 8: Diodes
Diodes are components which are polarized. They only
allow electrical current to pass through them in one
direction.This is useful in that it can be placed in a
circuit to prevent electricity from flowing in the wrong
direction.
www.karkhana.club
18Make Things with Arduino – Karkhana Makerspace©
The ring found on one end of the diode indicates the
side of the diode which connects to ground. This is the
cathode. It then follows that the other side connects to
power. This side is the anode.
They are represented in schematic as a line with a
triangle pointing at it. The line is that side which
connected to ground and the bottom of the triangle
connects to power.
Step 9: Transistors
www.karkhana.club
19Make Things with Arduino – Karkhana Makerspace©
A transistor takes in a small electrical current at its
base pin and amplifies it such that a much larger
current can pass between its collector and emitter pins.
The amount of current that passes between these two
pins is proportional to the voltage being applied at the
base pin.
There are two basic types of transistors, which are NPN
and PNP. These transistors have opposite polarity
between collector and emitter.
 NPN transistors allow electricity to pass from
the collector pin to the emitter pin. They are
www.karkhana.club
20Make Things with Arduino – Karkhana Makerspace©
represented in a schematic with a line for a
base, a diagonal line connecting to the base,
and a diagonal arrow pointing away from the
base.
 PNP transistors allow electricity to pass from
the emitter pin to the collector pin. They are
represented in a schematic with a line for a
base, a diagonal line connecting to the base,
and a diagonal arrow pointing towards the
base.
Step 10: Integrated Circuits
www.karkhana.club
21Make Things with Arduino – Karkhana Makerspace©
An integrated circuit is an entire specialized circuit that
has been miniaturized and fit onto one small chip with
each leg of the chip connecting to a point within the
circuit. These miniaturized circuits typically consist of
components such as transistors, resistors, and diodes.
Step 11: Potentiometers
Potentiometers are variable resistors. In plain English,
they have some sort of knob or slider that you turn or
push to change resistance in a circuit. If you have ever
www.karkhana.club
22Make Things with Arduino – Karkhana Makerspace©
used a volume knob on a stereo or a sliding light
dimmer, then you have used a potentiometer.
Potentiometers are measured in ohms like resistors,
but rather than having color bands, they have their
value rating written directly on them.
www.karkhana.club
23Make Things with Arduino – Karkhana Makerspace©
Step 12: LEDs
LED stands for light emitting diode. It is basically a
special type of diode that lights up when electricity
passes through it. Like all diodes, the LED is polarized
and electricity is only intended to pass through in one
direction.
www.karkhana.club
24Make Things with Arduino – Karkhana Makerspace©
How to find the anode and cathode of the LED?
i) The LED has a longer positive lead
(anode).
ii) A shorter ground or negative lead
(cathode).
iii) And The other indicator is a flat notch on
the side of the LED to indicate the
negative (cathode) lead. Keep in mind
that not all LEDs have this indication
notch (or that it is sometimes wrong).
www.karkhana.club
25Make Things with Arduino – Karkhana Makerspace©
Step 13: Switches
A switch is basically a mechanical device that creates a
break in a circuit. When you activate the switch,
it opens or closes the circuit. This is dependent on the
type of switch it is.
Normally open (N.O.) switches close the circuit when
activated.
Normally closed (N.C.) switches open the circuit when
activated.
www.karkhana.club
26Make Things with Arduino – Karkhana Makerspace©
Step 14: Batteries
A battery is a container which converts chemical
energy into electricity. To over-simplify the matter, you
can say that it "stores power."
By placing batteries in series you are adding the voltage
of each consecutive battery, but the current stays the
same.For instance, a AA-battery is 1.5V. If you put 3 in
series, it would add up to 4.5V.
If you were to add a fourth in series, it would then
become 6V.
www.karkhana.club
27Make Things with Arduino – Karkhana Makerspace©
By placing batteries in parallel the voltage remains the
same,but the amount of current available doubles.
Step 15: Breadboards
Breadboards are special boards for prototyping
electronics. They are covered with a grid of holes,
which are split into electrically continuous rows.
In the central part there are two columns of rows that
are side-by-side. This is designed to allow you to be
www.karkhana.club
28Make Things with Arduino – Karkhana Makerspace©
able to insert an integrated circuit into the center.
After it is inserted, each pin of the integrated circuit
will have a row of electrically continuous holes
connected to it.
Step 16: Wire
In order to connect things together using a breadboard,
you either need to use a component or a wire.
Wires are nice because they allow you to connect
things without adding virtually no resistance to the
circuit. This allows you to be flexible as to where you
place parts because you can connect them together
www.karkhana.club
29Make Things with Arduino – Karkhana Makerspace©
later with wire. It also allows you to connect a part to
multiple other parts.
Step 17: Your First Circuit
www.karkhana.club
30Make Things with Arduino – Karkhana Makerspace©
www.karkhana.club
31Make Things with Arduino – Karkhana Makerspace©
Parts List:
a) 1K ohm - 1/4 Watt resistor
b) 5mm red LED
c) SPST toggle switch
d) 9V battery connector
www.karkhana.club
32Make Things with Arduino – Karkhana Makerspace©
If you look at the schematic you will see that the 1K
resistor, LED, and switch are all connected in series
with the 9V battery. When you build the circuit, you
will be able to turn the LED on and off with the switch.
You can look up the color code for a 1K resistor using
the graphical resistance calculator. Also, remember
that the LED needs to be plugged in the right way (hint
- the long leg goes to the positive side of the circuit).
www.karkhana.club
33Make Things with Arduino – Karkhana Makerspace©
Want to organise Training Program in your campus:
Contact Us:
+91-93371951963 / +91-9348182664
Courses we offer:
1. Internet of Things
2. Machine Learning
3. Data Science
4. Emebdded Systems
5. Python
6. Robotics
7. Raspberry Pi
8. Image Processing
9. Android Application Design
10. MATLAB
11. Data Structure and Algorithm
www.karkhana.club
34Make Things with Arduino – Karkhana Makerspace©
www.karkhana.club
35Make Things with Arduino – Karkhana Makerspace©
Chapter 1
Getting Started
The purpose of this book is to get you started on the
road to creating things using micro-controllers. We will
discuss only enough electronics for you to make the
circuits, and only enough programming for you to get
started. The focus will be on your making things. It is
my hope that as you go through this book you will be
flooded with ideas of things that you can make.
So let’s get going...
The first question we’ll start with is:
1.1 What is a Microcontroller?
Wikipedia says:
A micro-controller is a small computer on a single
integrated circuit containing a processor core, memory,
and programmable input/ output peripherals The
important part for us is that amicro-controller contains
the processor (which all computers have) and memory,
and some input/output pins that you can control.
www.karkhana.club
36Make Things with Arduino – Karkhana Makerspace©
(often called GPIO - General Purpose Input Output
Pins).
1. Introduction
i) Arduino is an open-source electronics
prototyping platform based on flexible,
easy-to use hardware and software.
ii) It’s intended for artists, designers,
hobbyists, and anyone interested in
creating interactive objects or
environments.
iii) Arduino can sense the environment by
receiving input from a variety of sensors
www.karkhana.club
37Make Things with Arduino – Karkhana Makerspace©
and can affect its surroundings by
controlling lights, motors, and other
actuators.
iv) The microcontroller on the board is
programmed using the Arduino
programming language and the Arduino
Development Environment.
v) Arduino projects can be stand-alone, or
they can communicate with software
running on a computer.
vi) There are plenty of other microcontrollers
available. So you may be asking, why
choose the Arduino? Arduino really
simplifies the process of building projects
on a microcontroller making it a great
platform for amateurs.
vii) You can easily start working on one with
no previous electronics experience.
In addition to Arduino’s simplicity, it is also
inexpensive, cross-platform and open source. The
Arduino is based on Atmel’s ATMEGA8 and
ATMEGA168 microcontrollers. The plans for the
www.karkhana.club
38Make Things with Arduino – Karkhana Makerspace©
modules are published under a Creative Commons
license, so experienced hobbyists and professionals can
make their own version of the Arduino, extending it
and improving it.
Why Arduino?
Thanks to its simple and accessible user experience,
Arduino has been used in thousands of different
projects and applications. The Arduino software is
easy-to-use for beginners, yet flexible enough for
advanced users.
 Inexpensive - Arduino boards are relatively inexpensive
compared to other microcontroller platforms. The least
expensive version of the Arduino module can be
assembled by hand, and even the pre-assembled
Arduino modules cost less than $50
 Cross-platform - The Arduino Software (IDE) runs on
Windows, Macintosh OSX, and Linux operating
systems. Most microcontroller systems are limited to
Windows.
www.karkhana.club
39Make Things with Arduino – Karkhana Makerspace©
 Simple, clear programming environment - The Arduino
Software (IDE) is easy-to-use for beginners, yet flexible
enough for advanced users to take advantage of as
well. For teachers, it's conveniently based on the
Processing programming environment, so students
learning to program in that environment will be
familiar with how the Arduino IDE works.
 Open source and extensible software - The Arduino
software is published as open source tools, available
for extension by experienced programmers. The
language can be expanded through C++ libraries, and
people wanting to understand the technical details can
make the leap from Arduino to the AVR C programming
language on which it's based. Similarly, you can add
AVR-C code directly into your Arduino programs if you
want to.
 Open source and extensible hardware - The plans of
the Arduino boards are published under a Creative
Commons license, so experienced circuit designers can
make their own version of the module, extending it and
improving it. Even relatively inexperienced users can
build the breadboard version of the module in order to
understand how it works and save money.
www.karkhana.club
40Make Things with Arduino – Karkhana Makerspace©
What Can You Do With an Arduino?
There is a lot you can do with an Arduino. An Arduino
can basically do anything by interfacing sensors with a
computer. This would allow you to take any sensor and
have any action applied with the readings. For example
(in one of our projects) we will read the level of light in
a room and adjust an LED’s brightness to react based
on that input. This of course is a simple example of
what you can do with an Arduino. A more complicated
example would be to read from multiple sensors and
use that data to affect other outputs. Think of the
possibility of wiring your house with all sorts of
different sensors (photocells, oxygen sensors,
thermometers) and having it adjust your blinds, air
conditioner and furnace and make your house a more
comfortable place. Hackers have used Arduinos to
create some amazing electronics projects.
www.karkhana.club
41Make Things with Arduino – Karkhana Makerspace©
Things like:
• Robots
• Breathalyzers
• Remote controlled cars
• 3d printers
• Video games
• Home automation systems
• Million More ....
www.karkhana.club
42Make Things with Arduino – Karkhana Makerspace©
What Is Inside an Arduino?
www.karkhana.club
43Make Things with Arduino – Karkhana Makerspace©
Although there are many different types of Arduino
boards available, this manual focuses on the Arduino
Uno. This is the most popular Arduino board around.
So what makes this thing tick?
Here are the specifications:
• Processor: 16 Mhz ATmega328
• Flash memory: 32 KB
• Ram: 2kb
• Operating Voltage: 5V
• Input Voltage: 7-12 V
• Number of analog inputs: 6
• Number of digital I/O: 14 (6 of them pwm)
The specs may seem meager compared to your
desktop computer, but remember that the Arduino is
an embedded device. We have a lot less to process
than your desktop. Another wonderful feature of the
Arduino is the ability to use what are called “Shields”.
Although we will not be covering shields in this manual,
an Arduino shield will give you crazy functionality like
you wouldn’t believe. Check out this list of some really
cool Arduino shields to take your projects to the next
level.
www.karkhana.club
44Make Things with Arduino – Karkhana Makerspace©
The Integrated Development Environment (IDE)
You use the Arduino IDE on your computer (picture
following) to create, open, and change sketches
(Arduino calls programs “sketches”. We will use the
two words interchangeably in this book.). Sketches
www.karkhana.club
45Make Things with Arduino – Karkhana Makerspace©
define what the boardwill do. You can either use the
buttons along the top of the IDE or the menu items.
Our First Circuit
Before we get to the programming, let’s connect an
LED. LED stands for Light Emitting Diode. If you
connect the LED directly to power and ground, too
much current will go through the diode and destroy it.
To keep that from happening we will use a resistor to
limit the current. You can think of a resistor like a water
pipe. The higher the value of the resistor is like using a
smaller pipe that lets less electricity “flow” through.
This is not technically correct, but it is close enough for
this book. We will use a 330 Ohm (Ohm is often shown
as !) resistor (Resistance is measured in ohms. A 330!
resistor will have color bands: Orange-Orange-Brown)It
doesn’t matter which way you plug in a resistor. The
two leads (sometimes called “legs”) of an LED are
called an anode and a cathode. The anode is the longer
lead. IMPORTANT: IF YOU PLUG IT IN BACKWARDS, IT
WILL NOT WORK. (But it won’t be damaged, either.
Don’t worry).
www.karkhana.club
46Make Things with Arduino – Karkhana Makerspace©
Our First Program
Now let’s write a program to control the LED. Each
program must contain at least two functions. A
function is a series of programming statements that
can be called by name.
 setup() which is called once when the
program starts.
 loop() which is called repetitively over
and over again as long as the Arduino
has power.
1. Simplest Program
void setup()
{
}
void loop()
{
}
www.karkhana.club
47Make Things with Arduino – Karkhana Makerspace©
Blinking of LED
// the setup function runs once when you press reset
or power the board
void setup()
{
// initialize digital pin LED_BUILTIN as an output.
pinMode(13, OUTPUT);
}
// the loop function runs over and over again forever
void loop()
{
digitalWrite (13, HIGH); // turn the LED on (HIGH is
the voltage level)
delay(1000); // wait for a second
digitalWrite (13, LOW); //turn the LED off by making
the voltage LOW
delay(1000); // wait for a second
}
www.karkhana.club
48Make Things with Arduino – Karkhana Makerspace©
www.karkhana.club
49Make Things with Arduino – Karkhana Makerspace©
Projects To Do :
Do it yourself.
Led pattern
a) 2leds
b) 4leds
c) 8leds
a) Forward pattern
b) Backward pattern
c) Even numbers leds/odd numbers leds
THINKING?
Join our hands-on training courses.
To know more visit us at http://www.karkhana.club/
www.karkhana.club
50Make Things with Arduino – Karkhana Makerspace©
RGB LED
Their are two type of RGB led:
i) Common Cathode
ii) Common Anode
www.karkhana.club
51Make Things with Arduino – Karkhana Makerspace©
For Common Cathode:
www.karkhana.club
52Make Things with Arduino – Karkhana Makerspace©
www.karkhana.club
53Make Things with Arduino – Karkhana Makerspace©
Code:
void setup()
{
pinMode(1,OUTPUT);
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
}
void loop()
{
digitalWrite(1,HIGH);
delay(1000);
digitalWrite(1,LOW);
delay(1000);
digitalWrite(2,HIGH);
delay(1000);
digitalWrite(2,LOW);
delay(1000);
digitalWrite(3,HIGH);
delay(1000);
digitalWrite(3,LOW);
}
www.karkhana.club
54Make Things with Arduino – Karkhana Makerspace©
For Common Anode:
www.karkhana.club
55Make Things with Arduino – Karkhana Makerspace©
Code:
void setup()
{
pinMode(1,OUTPUT);
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
}
void loop()
{
digitalWrite(1,LOW);
delay(1000);
digitalWrite(1,HIGH);
delay(1000);
digitalWrite(2,LOW);
delay(1000);
digitalWrite(2,HIGH);
delay(1000);
digitalWrite(3,LOW);
delay(1000);
digitalWrite(3,HIGH);
}
www.karkhana.club
56Make Things with Arduino – Karkhana Makerspace©
Matrix of LED
www.karkhana.club
57Make Things with Arduino – Karkhana Makerspace©
Code:
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(0, OUTPUT);
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(0, HIGH);
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
delay(100);
digitalWrite(0, LOW);
digitalWrite(1, HIGH);
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
delay(100);
}
Now apply your own logic and try to generate your
own patterns.
www.karkhana.club
58Make Things with Arduino – Karkhana Makerspace©
Their are LEDs inside the seven segment dispaly. Try to
make your own seven segment.
Need more help. Visit :
http://karkhanaindia.blogspot.in
www.karkhana.club
59Make Things with Arduino – Karkhana Makerspace©
Push Button
What is a pushbutton?
A device designed to close or open an electric circuit
when a button or knob is depressed, and to return to a
normal position when it is released.
www.karkhana.club
60Make Things with Arduino – Karkhana Makerspace©
How to interface pushbutton to arduino?
Since now we are well acquainted with LED’s let us
learn how to control the switching using a push button.
A push button is used to get control of the circuit.
Components Required
 Resistors 2Nos.
330ohms,10k(recommended)
 Pushbutton 1No.
 LED 1No. Standard red LED
 Arduino UNO
 Breadboard
www.karkhana.club
61Make Things with Arduino – Karkhana Makerspace©
Now dump the code given below
int d=2; // chose the pin which you have
connected to the output of push button
void setup()
{
pinMode(2,INPUT);
pinMode(13,OUTPUT);
}
void loop()
{
d=digitalRead(2);
if(d==0)
{
www.karkhana.club
62Make Things with Arduino – Karkhana Makerspace©
digitalWrite(13,HIGH);
}
else
{
digitalWrite(13,LOW);
}
}
Now the control is in your hands whenever you will
press the button the led will be ON and when you
release it, LED will go OFF.
You can alter the control like:
https://youtu.be/DlaVtHpsrJs
Here when we press the button LED goes ON and when
we press it again it goes OFF.
For the code of the above video mail us at :
hello@karkhana.club
I hope you are having fun, try connecting multiple
switches with multiple LEDs.
www.karkhana.club
63Make Things with Arduino – Karkhana Makerspace©
 A pull-up resistor condition.
When the switch is connected to ground and
one end of the resistor is connected to VCC.
www.karkhana.club
64Make Things with Arduino – Karkhana Makerspace©
 Pull down resistor condition.
When one end of the switch is connected to Vcc and
the resistor is connected to ground.
When you use these conditions while coding just
remembers when you press the switch, one will give
output as 0 and the other will give output as 1.
Do it yourself
Logic gates
i) And gate
ii) Or gate
iii) Not gate
www.karkhana.club
65Make Things with Arduino – Karkhana Makerspace©
Seven Segment Display
A 7 SEGMENT DISPLAY consists of 8 LEDs and 10 pins,2
common pins are shorted and supplied with 5 volts
from Arduino through a resistor and other 8 pins are
connected to digital and analog pins.
7 Segment Display can act as a substitute for LCDs if we
want to display numbers.
www.karkhana.club
66Make Things with Arduino – Karkhana Makerspace©
Shown below is the internal architecture of a 7
segment display.
There are two types of LED 7-segment display
 Common cathode (CC)
 Common anode (CA)
In CC type the cathode of all the LEDs is connected
together and similarly in CA type.
www.karkhana.club
67Make Things with Arduino – Karkhana Makerspace©
In CC type we have to ground the common cathode pin
and power up segments to illuminate it, the reverse
happens for CA types. Here we have to power up the
common anode pin and provide ground to segments
according to our requirements of illuminations.
How to interface a 7 segment display with Arduino?
Now let’s interface the 7 SEGMENT DISPLAY.
Components Required
 Arduino Uno 1No.
 7 Segment Display 1No.
 Resistors 1No. 100 ohms
 Connecting Wires
 Breadboard
www.karkhana.club
68Make Things with Arduino – Karkhana Makerspace©
The below code can be used to display digits from Zero
to Nine.
void setup()
{
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
}
www.karkhana.club
69Make Things with Arduino – Karkhana Makerspace©
void loop()
{ // ZERO
digitalWrite(2,LOW);
digitalWrite(3,HIGH);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,LOW);
digitalWrite(8,LOW);
digitalWrite(9,LOW);
delay(1000);
// Zero off
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
delay(1000); // ONE
digitalWrite(4,LOW);
digitalWrite(6,LOW);
www.karkhana.club
70Make Things with Arduino – Karkhana Makerspace©
delay(1000);
//1 off
digitalWrite(4,HIGH);
digitalWrite(6,HIGH);
delay(1000);
//2 0N
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,LOW);
delay(1000);
//2 0ff
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
delay(1000);
//3 0n
www.karkhana.club
71Make Things with Arduino – Karkhana Makerspace©
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(5,LOW);
digitalWrite(7,LOW);
digitalWrite(8,LOW);
delay(1000);
//3 0ff
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(5,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
delay(1000);
//4 on
digitalWrite(3,LOW);
www.karkhana.club
72Make Things with Arduino – Karkhana Makerspace©
 You can also use IC 7446 which is a BCD to 7
segment decoder by which you can display all
your digits with the combination of four
inputs.Connect the IC as shown below.
www.karkhana.club
73Make Things with Arduino – Karkhana Makerspace©
A Buzzer (or Piezo Speaker)
An electrical device that makes a buzzing noise and is
used for signalling.
For this you will need:
 Arduino uno
 Breadboard
 Buzzer / piezo speaker
 100 Ohm resistor (optional)
www.karkhana.club
74Make Things with Arduino – Karkhana Makerspace©
Code
void setup()
{
pinMode(7, OUTPUT); // Set buzzer - pin 7 as
an output
}
void loop()
{
digitalWrite(7, HIGH); // buzzer will on
delay(1000); // buzz for 1 sec
digitalWrite(7,LOW); // buzzer will off
delay(1000); // off for 1 sec
}
www.karkhana.club
75Make Things with Arduino – Karkhana Makerspace©
Buzzer With Push Button
For this you will need:
 Arduino uno
 Breadboard
 Buzzer / piezo speaker
 220 Ohm resistor -2 no.
 Push button
www.karkhana.club
76Make Things with Arduino – Karkhana Makerspace©
Code
int d=2; // chose the pin which you
have connected to the output of push button
void setup()
{
pinMode(2,INPUT);
pinMode(13,OUTPUT);
}
void loop()
{
d=digitalRead(2);
if(d==0)
{ digitalWrite(13,HIGH);
}
else
{ digitalWrite(13,LOW);
}
}
www.karkhana.club
77Make Things with Arduino – Karkhana Makerspace©
IR Sensor
A sensor is a device which detects or measures a
physical property and records, indicates or otherwise
responds to it. Digital sensors give us output in the
form of HIGH or LOW signal.
When it detects a phenomenon it gives a HIGH output
else a LOW output signal.
Few examples of digital sensors are-IR Sensors, Digital
Sound Sensors, Digital Temperature Sensors etc.
We will interface an Infrared Sensor module.
www.karkhana.club
78Make Things with Arduino – Karkhana Makerspace©
i) Working on an IR sensor.
ii) It basically works as an obstacle detector.
iii) Let us learn how to interface an IR
(infrared) sensor.
Components required:
 IR sensor module 1No.
 Arduino UNO 1No
 Connecting wires.
 Breadboard.
 LED
www.karkhana.club
79Make Things with Arduino – Karkhana Makerspace©
TASK 1 : Can You Design The Circuit By Code.
Code
int d;
void setup() {
pinMode(12, OUTPUT);
pinMode(16, INPUT);
}
void loop() {
d = digitalRead(16);
if (d == LOW) {
digitalWrite(12, HIGH);
} else {
digitalWrite(12, LOW);
}
}
Thinking?
. Visit : http://www.karkhana.club/
www.karkhana.club
80Make Things with Arduino – Karkhana Makerspace©
LCD (Liquid Crystal Display)
An LCD screen is an electronic display module having a
flat panel display or we can say it’s an electronically
modulated optical device that uses the light
modulating properties of liquid crystals.
www.karkhana.club
81Make Things with Arduino – Karkhana Makerspace©
How to interface an LCD (liquid crystal display) with
ARDUINO ?
We will interface a 16x2(16 columns and 2 rows) LCD.
Other variations are also available like 8x1,10x2 etc.
It is having a wide range of applications; they are also
preferred over 7-segment display as they are cheap,
easily programmable and also have the leverage to
display special characters.
www.karkhana.club
82Make Things with Arduino – Karkhana Makerspace©
Now let us interface
Components Required
 16x2 LCD 1No.
 Resistor 560ohms 1No.
 Potentiometer 10k 1No.
 Arduino UNO 1No.
 Few connecting wires
 Breadboard
Follow the image below for circuit connection
reference.
www.karkhana.club
83Make Things with Arduino – Karkhana Makerspace©
After making the circuit dump the code given below.
#include<LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup()
{
lcd.begin(16, 2);
}
void loop()
{
lcd.setCursor(0,0);
lcd.print("WELCOME TO");
lcd.setCursor(2,1);
lcd.print("SUDOLEARN TECH");
}
The potentiometer can be used to control the contrast
of your display.
You can use an LCD to display the output of your
projects instead of showing them in the serial monitor,
providing a display to the system will make your system
independent and interactive.
www.karkhana.club
84Make Things with Arduino – Karkhana Makerspace©
 Data is transferred in 4 bits to the pins D4-D7.
 LCD has its own controller named Hitachi
HD44780 LCD controller.
Task :
i) Hello word
ii) Multiplication of 2,3,4,5,6,7,8,9
iii) Passwords (using switch)
iv) Game (football , gun)
Thinking?
Visit : http://karkhanaindia.blogspot.in
www.karkhana.club
85Make Things with Arduino – Karkhana Makerspace©
Sensors
LDR (Light Dependent Resistor)
A light dependent resistor (LDR) or a photo resistor is a
device whose resistivity is a function of the incident
electromagnetic radiation. Hence, they are light
sensitive devices. They are also called as photo
conductors, photo conductive cell or simply photocells.
www.karkhana.club
86Make Things with Arduino – Karkhana Makerspace©
This is simple arduino project; turn on LED when it's
dark and turn off when is light.
Hardware Required :
 Arduino Uno
 LED
 LDR (photoresistor)
 220 and 10k ohm resistors
 Wires
 Breadboard
 Led
www.karkhana.club
87Make Things with Arduino – Karkhana Makerspace©
Code
const int ledPin = 13;
const int ldrPin = A0;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(ldrPin, INPUT);
}
void loop() {
int ldrStatus = analogRead(ldrPin);
if (ldrStatus <=300) {
digitalWrite(ledPin, HIGH);
}
else {
digitalWrite(ledPin, LOW);
}
}
Try it yourself:
1. Do same thing with tempaerture sensor
(LM35)
www.karkhana.club
88Make Things with Arduino – Karkhana Makerspace©
Ultrasonic sensor
An Ultrasonic sensor is a device that can measure the
distance to an object by using sound waves. It
measures distance by sending out a sound wave at a
specific frequency and listening for that sound wave to
bounce back. By recording the elapsed time between
the sound wave being generated and the sound wave
bouncing back, it is possible to calculate the distance
between the sonar sensor and the object.
www.karkhana.club
89Make Things with Arduino – Karkhana Makerspace©
The HC-SR04 Ultrasonic Module has 4 pins, Ground,
VCC, Trig and Echo. The Ground and the VCC pins of
the module needs to be connected to the Ground and
the 5 volts pins on the Arduino Board respectively and
the trig and echo pins to any Digital I/O pin on the
Arduino Board.
www.karkhana.club
90Make Things with Arduino – Karkhana Makerspace©
Parts List
- Arduino Board
- Ultrasonic Sensor HC-SR04
- Buzzer
- LED
- 220ohm Resistor
- Breadboard and Jump Wires
www.karkhana.club
91Make Things with Arduino – Karkhana Makerspace©
Code Descriptions:
- First you have to define the Trig and Echo pins. In this
case they are the pins number 9 and 10 on the Arduino
Board and they are named trigPin and echoPin. Then
you need a Long variable, named “duration” for
the travel time that you will get from the sensor and an
integer variable for the distance.
- In the setup you have to define the trigPin as an
output and the echoPin as an Input and also start the
serial communication for showing the results on the
serial monitor.
- If the object is 10 cm away from the sensor, and the
speed of the sound is 340 m/s or 0.034 cm/µs the
sound wave will need to travel about 294 u seconds.
But what you will get from the Echo pin will be double
that number because the sound wave needs to travel
forward and bounce backward. So in order to get the
distance in cm we need to multiply the received travel
time value from the echo pin by 0.034 and divide it by
2.
www.karkhana.club
92Make Things with Arduino – Karkhana Makerspace©
Get the code :
defines pins numbers
const int trigPin = 9;
const int echoPin = 10;
const int buzzer = 11;
const int ledPin = 13;
long duration;
int distance;
int safetyDistance;
void setup()
{
pinMode(trigPin, OUTPUT);
// Sets the trigPin as an Output
pinMode(echoPin, INPUT);
// Sets the echoPin as an Input
pinMode(buzzer, OUTPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
// Starts the serial communication
}
www.karkhana.club
93Make Things with Arduino – Karkhana Makerspace©
void loop() {
// Clears the trigPin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
//Calculating the distance
distance= duration*0.034/2;
safetyDistance = distance;
if (safetyDistance <= 5){
digitalWrite(buzzer, HIGH);
digitalWrite(ledPin, HIGH);
}
else{
digitalWrite(buzzer, LOW);
digitalWrite(ledPin, LOW);
}
// Prints the distance on the Serial Monitor
Serial.print("Distance: ");
Serial.println(distance);
}
www.karkhana.club
94Make Things with Arduino – Karkhana Makerspace©
LED Brightness Control
Hardware Required
 Arduino or Genuino Board
 LED
 220 ohm resistor
Circuit
Connect the 220 ohm current limiting resistor to digital
pin 9, with an LED in series. The long, positive leg (the
anode) of the LED should be connected to the output
from the resistor, with the shorter, negative leg (the
cathode) connected to ground.
Code it yourself !
Hint : analogWrite(3, x); // Range of x = 0-255
Analog Output Pin on Arduino Uno/Nano/Mini –
3,5,6,9,10 & 11
www.karkhana.club
95Make Things with Arduino – Karkhana Makerspace©
Schematic
www.karkhana.club
96Make Things with Arduino – Karkhana Makerspace©

More Related Content

What's hot

Fundamentals of electrical and electronics engineering
Fundamentals of electrical and electronics engineeringFundamentals of electrical and electronics engineering
Fundamentals of electrical and electronics engineeringHomework Guru
 
Basic electrical comp upload1
Basic electrical comp upload1Basic electrical comp upload1
Basic electrical comp upload1Ganesh Kumar
 
Introduction to Basic Electronics
Introduction to Basic ElectronicsIntroduction to Basic Electronics
Introduction to Basic ElectronicsCiel Rampen
 
Basics of Electronics
Basics of ElectronicsBasics of Electronics
Basics of ElectronicsVarun A M
 
Report Automatic led emergency light
Report Automatic led emergency lightReport Automatic led emergency light
Report Automatic led emergency lightVatsal N Shah
 
Automatic emergency light using led ppt
Automatic emergency light using led pptAutomatic emergency light using led ppt
Automatic emergency light using led pptRitik Joshi
 
Light sensor (on when dark)
Light sensor (on when dark)Light sensor (on when dark)
Light sensor (on when dark)MrTalha
 
Automatic led emergency light
Automatic led emergency lightAutomatic led emergency light
Automatic led emergency lightsahadev1992
 
Basics of Electronics
Basics of ElectronicsBasics of Electronics
Basics of ElectronicsThink LABS
 
Mini emergency-light
Mini emergency-lightMini emergency-light
Mini emergency-lightER Punit Jain
 
Components Used In Electrical and Electronic Projects
Components Used In Electrical and Electronic ProjectsComponents Used In Electrical and Electronic Projects
Components Used In Electrical and Electronic ProjectsEdgefxkits & Solutions
 
Dictionary electric
Dictionary electricDictionary electric
Dictionary electricLucas Cjs
 
Basic Electronics components
Basic Electronics componentsBasic Electronics components
Basic Electronics componentsvaibhav jindal
 

What's hot (20)

Fundamentals of electrical and electronics engineering
Fundamentals of electrical and electronics engineeringFundamentals of electrical and electronics engineering
Fundamentals of electrical and electronics engineering
 
Basic electrical comp upload1
Basic electrical comp upload1Basic electrical comp upload1
Basic electrical comp upload1
 
Report
ReportReport
Report
 
Introduction to Basic Electronics
Introduction to Basic ElectronicsIntroduction to Basic Electronics
Introduction to Basic Electronics
 
Electronic letter box
Electronic letter boxElectronic letter box
Electronic letter box
 
Basics of Electronics
Basics of ElectronicsBasics of Electronics
Basics of Electronics
 
Report Automatic led emergency light
Report Automatic led emergency lightReport Automatic led emergency light
Report Automatic led emergency light
 
basic electronics
basic    electronicsbasic    electronics
basic electronics
 
BASIC ELECTRONICS
BASIC ELECTRONICS BASIC ELECTRONICS
BASIC ELECTRONICS
 
Automatic emergency light using led ppt
Automatic emergency light using led pptAutomatic emergency light using led ppt
Automatic emergency light using led ppt
 
Light sensor (on when dark)
Light sensor (on when dark)Light sensor (on when dark)
Light sensor (on when dark)
 
Automatic led emergency light
Automatic led emergency lightAutomatic led emergency light
Automatic led emergency light
 
Basics of Electronics
Basics of ElectronicsBasics of Electronics
Basics of Electronics
 
Electronics
ElectronicsElectronics
Electronics
 
Mini emergency-light
Mini emergency-lightMini emergency-light
Mini emergency-light
 
Components Used In Electrical and Electronic Projects
Components Used In Electrical and Electronic ProjectsComponents Used In Electrical and Electronic Projects
Components Used In Electrical and Electronic Projects
 
Dictionary electric
Dictionary electricDictionary electric
Dictionary electric
 
Basic Electronics components
Basic Electronics componentsBasic Electronics components
Basic Electronics components
 
Electrical circuit
Electrical circuitElectrical circuit
Electrical circuit
 
Ldrppt
LdrpptLdrppt
Ldrppt
 

Similar to Getting Started with Arduino

Electronics 01
Electronics 01Electronics 01
Electronics 01snakeaye
 
Ac dc and circuits
Ac dc and circuitsAc dc and circuits
Ac dc and circuitssbarkanic
 
Elecronz_Chapter_1.pptx
Elecronz_Chapter_1.pptxElecronz_Chapter_1.pptx
Elecronz_Chapter_1.pptxMokete5
 
Additional Science P2.3 Electricity
Additional Science P2.3 ElectricityAdditional Science P2.3 Electricity
Additional Science P2.3 ElectricitySteve Bishop
 
Automatic IN/OUT Indicator with Doorbell Manual
Automatic IN/OUT Indicator with Doorbell ManualAutomatic IN/OUT Indicator with Doorbell Manual
Automatic IN/OUT Indicator with Doorbell ManualTezpur University
 
Cyberlab School Robotics Workshop
Cyberlab School Robotics WorkshopCyberlab School Robotics Workshop
Cyberlab School Robotics WorkshopVivek chan
 
EWB practical workbook
EWB practical  workbookEWB practical  workbook
EWB practical workbookserjani
 
Resonant Response of RLC Circuits
Resonant Response of RLC Circuits Resonant Response of RLC Circuits
Resonant Response of RLC Circuits Sachin Mehta
 
Invisible broken wire detector
Invisible broken wire detectorInvisible broken wire detector
Invisible broken wire detectorRITESH D. PATIL
 
1.pptx4168484105164649489481510120165165161
1.pptx41684841051646494894815101201651651611.pptx4168484105164649489481510120165165161
1.pptx4168484105164649489481510120165165161vikknaguem
 
Learn about the three most widely used electronic components
Learn about the three most widely used electronic componentsLearn about the three most widely used electronic components
Learn about the three most widely used electronic componentsexpess-technology
 
Introduction to electronics - Third session
Introduction to electronics - Third sessionIntroduction to electronics - Third session
Introduction to electronics - Third sessionKareem Elzftawy
 

Similar to Getting Started with Arduino (20)

Electronics 01
Electronics 01Electronics 01
Electronics 01
 
Ac dc and circuits
Ac dc and circuitsAc dc and circuits
Ac dc and circuits
 
elecabsbegin.pdf
elecabsbegin.pdfelecabsbegin.pdf
elecabsbegin.pdf
 
Elecronz_Chapter_1.pptx
Elecronz_Chapter_1.pptxElecronz_Chapter_1.pptx
Elecronz_Chapter_1.pptx
 
Additional Science P2.3 Electricity
Additional Science P2.3 ElectricityAdditional Science P2.3 Electricity
Additional Science P2.3 Electricity
 
Automatic IN/OUT Indicator with Doorbell Manual
Automatic IN/OUT Indicator with Doorbell ManualAutomatic IN/OUT Indicator with Doorbell Manual
Automatic IN/OUT Indicator with Doorbell Manual
 
Electricity
ElectricityElectricity
Electricity
 
Cyberlab School Robotics Workshop
Cyberlab School Robotics WorkshopCyberlab School Robotics Workshop
Cyberlab School Robotics Workshop
 
EWB practical workbook
EWB practical  workbookEWB practical  workbook
EWB practical workbook
 
Resonant Response of RLC Circuits
Resonant Response of RLC Circuits Resonant Response of RLC Circuits
Resonant Response of RLC Circuits
 
Report on inverters
Report on invertersReport on inverters
Report on inverters
 
Invisible broken wire detector
Invisible broken wire detectorInvisible broken wire detector
Invisible broken wire detector
 
1.pptx4168484105164649489481510120165165161
1.pptx41684841051646494894815101201651651611.pptx4168484105164649489481510120165165161
1.pptx4168484105164649489481510120165165161
 
Electrical wiring
Electrical wiringElectrical wiring
Electrical wiring
 
Electricity
ElectricityElectricity
Electricity
 
EEE Interview Question
EEE Interview QuestionEEE Interview Question
EEE Interview Question
 
2nd year iv sem emi lab manual
2nd year iv sem emi lab manual2nd year iv sem emi lab manual
2nd year iv sem emi lab manual
 
Learn about the three most widely used electronic components
Learn about the three most widely used electronic componentsLearn about the three most widely used electronic components
Learn about the three most widely used electronic components
 
Introduction to electronics - Third session
Introduction to electronics - Third sessionIntroduction to electronics - Third session
Introduction to electronics - Third session
 
Mobile detection
Mobile detectionMobile detection
Mobile detection
 

Recently uploaded

Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
 
Gyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptxGyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptxShibin Azad
 
2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptxmansk2
 
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxJose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxricssacare
 
Benefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational ResourcesBenefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational Resourcesdimpy50
 
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...Denish Jangid
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersPedroFerreira53928
 
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...Sayali Powar
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsCol Mukteshwar Prasad
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxbennyroshan06
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfVivekanand Anglo Vedic Academy
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfbu07226
 
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptxSolid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptxDenish Jangid
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXMIRIAMSALINAS13
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
 
The Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational ResourcesThe Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational Resourcesaileywriter
 
Accounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdfAccounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdfYibeltalNibretu
 

Recently uploaded (20)

Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Gyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptxGyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptx
 
2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx
 
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxJose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
 
Benefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational ResourcesBenefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational Resources
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
 
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
 
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptxSolid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
NCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdfNCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdf
 
The Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational ResourcesThe Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational Resources
 
Accounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdfAccounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdf
 

Getting Started with Arduino

  • 1. www.karkhana.club 1Make Things with Arduino – Karkhana Makerspace© By Siddharth Bhatter & Akash Verma This manual is the Intellectual property of Karkhana Makerspace. It must only be published in its origianl form. Using parts or republishing altered parts of this guide is prohibited without permission from Karkhana Makerspace
  • 2. www.karkhana.club 2Make Things with Arduino – Karkhana Makerspace© CHAPTER - 1 BASIC ELECTRONICS
  • 3. www.karkhana.club 3Make Things with Arduino – Karkhana Makerspace© 1. Basic Electronics Getting started with basic electronics is easier than you think.This instructable will hopefully demystify the basics of electronics so that anyone with an interest in building circuits can hit the ground running. This is a quick overview into practical electronics and it is not my goal to delve deeply into the science of electrical engineering. If you are interested in learning more about the science of basic electronics, Wikipedia is a good place to start your search. By the end of this Instructable, anyone with an interest to learn basic electronics should be able to read a schematic and build a circuit using standard electronic components.
  • 4. www.karkhana.club 4Make Things with Arduino – Karkhana Makerspace© 1.1 Electricity
  • 5. www.karkhana.club 5Make Things with Arduino – Karkhana Makerspace© There are two types of electrical signals :- a) Alternating Current (AC) Fig 1. Circuit Diagram with AC Source Fig 2. Waveform of AC signal With alternating current, the direction electricity flows throughout the circuit is constantly reversing. You may even say that it is alternating direction. The rate of
  • 6. www.karkhana.club 6Make Things with Arduino – Karkhana Makerspace© reversal is measured in Hertz, which is the number of reversals per second. So, when they say that the US power supply is 60 Hz, what they mean is that it is reversing 120 times per second (twice per cycle). b) Direct Current (DC) Waveform of DC signal Fig3.Circuit diagram with DC source
  • 7. www.karkhana.club 7Make Things with Arduino – Karkhana Makerspace© With Direct Current, electricity flows in one direction between power and ground. In this arrangement there is always a positive source of voltage and ground (0volt) source of voltage. 1.2 Circuit A circuit is a complete and closed path through which electric current can flow. In other words, a closed circuit would allow the flow of electricity between power and ground. An open circuit would break the flow of electricity between power and ground. Circuit
  • 8. www.karkhana.club 8Make Things with Arduino – Karkhana Makerspace© Anything that is part of this closed system and that allows electricity to flow between power and ground is considered to be part of the circuit. 1.3 Resistance In the circuit above, the motor that electricity is flowing through is adding resistance to the flow of electricity. Thus, all of the electricity passing through the circuit is being put to use. In other words, there needs to be something wired between positive and ground that adds resistance to the flow of electricity and uses it up. If positive voltage is connected directly to ground and does not first pass through something that adds resistance, like a motor, Resistance
  • 9. www.karkhana.club 9Make Things with Arduino – Karkhana Makerspace© this will result in a short circuit. This means that the positive voltage is connected directly to ground. Likewise, if electricity passes through a component (or group of components) that does not add enough resistance to the circuit, a short will likewise occur. Shorts are bad because they will result in your battery and/or circuit overheating, breaking, catching on fire, and/or exploding. It is very important to prevent short circuits by making sure that the positive voltage is never wired directly to ground.
  • 10. www.karkhana.club 10Make Things with Arduino – Karkhana Makerspace© 1.4 Series Vs. Parallel Series and Parallel Circuits There are two different ways in which you can wire things together called series and parallel. When things are wired in series, things are wired one after another, such that electricity has to pass through one thing, then the next thing, then the next, and so on. When things are wired in parallel, they are wired side by side, such that electricity passes through all of them at the same time, from one common point to another common point.
  • 11. www.karkhana.club 11Make Things with Arduino – Karkhana Makerspace© 1.5 Basic Components In order to build circuits, you will need to become familiar with a few basic components. These components may seem simple, but are the bread and butter of most electronics projects. Thus, by learning about these few basic parts, you will be able to go a long way.Bear with me as I elaborate as to what each of these are in the coming steps.
  • 12. www.karkhana.club 12Make Things with Arduino – Karkhana Makerspace© 1.6 Resistors As the name implies, resistors add resistance to the circuit and reduces the flow of electrical current. It is represented in a circuit diagram as a pointy squiggle with a value next to it. The different markings on the resistor represent different values of resistance. These values are measured in ohms. You read the values from left to right towards the (typically) gold band. The first two colors represent the resistor value, the third represents the multiplier, and
  • 13. www.karkhana.club 13Make Things with Arduino – Karkhana Makerspace© the fourth (the gold band) represents the tolerance or precision of the component. You can tell the value of each color by looking at a resistor color value chart. Or... to make your life easier, you could simply look up the values using a graphical resistance calculator. Anyhow... a resistor with the markings brown, black, orange, gold will translate as follows: 1 (brown) 0 (black) x 1,000 = 10,000 with a tolerance of +/- 5% Any resistor of over 1000 ohms is typically shorted using the letter K. For instance, 1,000 would be 1K; 3,900, would translate to 3.9K; and 470,000 ohms would become 470K.Values of ohms over a million are represented using the letter M. In this case, 1,000,000 ohms would become 1M.
  • 14. www.karkhana.club 14Make Things with Arduino – Karkhana Makerspace© 1.7 Capacitors A capacitor is a component that stores electricity and then discharges it into the circuit when there is a drop in electricity. You can think of it as a water storage tank that releases water when there is a drought to ensure a steady stream. Capacitors are measured in Farads. The values that you will typically encounter in most capacitors are measured in picofarad (pF), nanofarad (nF), and microfarad (uF).
  • 15. www.karkhana.club 15Make Things with Arduino – Karkhana Makerspace© Types of capacitor :- a) Electrolytic Capacitors  Electrolytic capacitors are typically polarized.  One leg needs to be connected to the ground side of the circuit and the other leg must be connected to power.  Electrolytic capacitors have the value written on them,typically represented in uF.  They also mark the leg which connects to ground with a minus symbol (-).
  • 16. www.karkhana.club 16Make Things with Arduino – Karkhana Makerspace© i) Ceramic Disc Capacitors  Ceramic disc capacitors are non-polarized.  Electricity can pass through them no matter how they are inserted in the circuit.  They are typically marked with a number code which needs to be decoded.
  • 17. www.karkhana.club 17Make Things with Arduino – Karkhana Makerspace© Step 8: Diodes Diodes are components which are polarized. They only allow electrical current to pass through them in one direction.This is useful in that it can be placed in a circuit to prevent electricity from flowing in the wrong direction.
  • 18. www.karkhana.club 18Make Things with Arduino – Karkhana Makerspace© The ring found on one end of the diode indicates the side of the diode which connects to ground. This is the cathode. It then follows that the other side connects to power. This side is the anode. They are represented in schematic as a line with a triangle pointing at it. The line is that side which connected to ground and the bottom of the triangle connects to power. Step 9: Transistors
  • 19. www.karkhana.club 19Make Things with Arduino – Karkhana Makerspace© A transistor takes in a small electrical current at its base pin and amplifies it such that a much larger current can pass between its collector and emitter pins. The amount of current that passes between these two pins is proportional to the voltage being applied at the base pin. There are two basic types of transistors, which are NPN and PNP. These transistors have opposite polarity between collector and emitter.  NPN transistors allow electricity to pass from the collector pin to the emitter pin. They are
  • 20. www.karkhana.club 20Make Things with Arduino – Karkhana Makerspace© represented in a schematic with a line for a base, a diagonal line connecting to the base, and a diagonal arrow pointing away from the base.  PNP transistors allow electricity to pass from the emitter pin to the collector pin. They are represented in a schematic with a line for a base, a diagonal line connecting to the base, and a diagonal arrow pointing towards the base. Step 10: Integrated Circuits
  • 21. www.karkhana.club 21Make Things with Arduino – Karkhana Makerspace© An integrated circuit is an entire specialized circuit that has been miniaturized and fit onto one small chip with each leg of the chip connecting to a point within the circuit. These miniaturized circuits typically consist of components such as transistors, resistors, and diodes. Step 11: Potentiometers Potentiometers are variable resistors. In plain English, they have some sort of knob or slider that you turn or push to change resistance in a circuit. If you have ever
  • 22. www.karkhana.club 22Make Things with Arduino – Karkhana Makerspace© used a volume knob on a stereo or a sliding light dimmer, then you have used a potentiometer. Potentiometers are measured in ohms like resistors, but rather than having color bands, they have their value rating written directly on them.
  • 23. www.karkhana.club 23Make Things with Arduino – Karkhana Makerspace© Step 12: LEDs LED stands for light emitting diode. It is basically a special type of diode that lights up when electricity passes through it. Like all diodes, the LED is polarized and electricity is only intended to pass through in one direction.
  • 24. www.karkhana.club 24Make Things with Arduino – Karkhana Makerspace© How to find the anode and cathode of the LED? i) The LED has a longer positive lead (anode). ii) A shorter ground or negative lead (cathode). iii) And The other indicator is a flat notch on the side of the LED to indicate the negative (cathode) lead. Keep in mind that not all LEDs have this indication notch (or that it is sometimes wrong).
  • 25. www.karkhana.club 25Make Things with Arduino – Karkhana Makerspace© Step 13: Switches A switch is basically a mechanical device that creates a break in a circuit. When you activate the switch, it opens or closes the circuit. This is dependent on the type of switch it is. Normally open (N.O.) switches close the circuit when activated. Normally closed (N.C.) switches open the circuit when activated.
  • 26. www.karkhana.club 26Make Things with Arduino – Karkhana Makerspace© Step 14: Batteries A battery is a container which converts chemical energy into electricity. To over-simplify the matter, you can say that it "stores power." By placing batteries in series you are adding the voltage of each consecutive battery, but the current stays the same.For instance, a AA-battery is 1.5V. If you put 3 in series, it would add up to 4.5V. If you were to add a fourth in series, it would then become 6V.
  • 27. www.karkhana.club 27Make Things with Arduino – Karkhana Makerspace© By placing batteries in parallel the voltage remains the same,but the amount of current available doubles. Step 15: Breadboards Breadboards are special boards for prototyping electronics. They are covered with a grid of holes, which are split into electrically continuous rows. In the central part there are two columns of rows that are side-by-side. This is designed to allow you to be
  • 28. www.karkhana.club 28Make Things with Arduino – Karkhana Makerspace© able to insert an integrated circuit into the center. After it is inserted, each pin of the integrated circuit will have a row of electrically continuous holes connected to it. Step 16: Wire In order to connect things together using a breadboard, you either need to use a component or a wire. Wires are nice because they allow you to connect things without adding virtually no resistance to the circuit. This allows you to be flexible as to where you place parts because you can connect them together
  • 29. www.karkhana.club 29Make Things with Arduino – Karkhana Makerspace© later with wire. It also allows you to connect a part to multiple other parts. Step 17: Your First Circuit
  • 30. www.karkhana.club 30Make Things with Arduino – Karkhana Makerspace©
  • 31. www.karkhana.club 31Make Things with Arduino – Karkhana Makerspace© Parts List: a) 1K ohm - 1/4 Watt resistor b) 5mm red LED c) SPST toggle switch d) 9V battery connector
  • 32. www.karkhana.club 32Make Things with Arduino – Karkhana Makerspace© If you look at the schematic you will see that the 1K resistor, LED, and switch are all connected in series with the 9V battery. When you build the circuit, you will be able to turn the LED on and off with the switch. You can look up the color code for a 1K resistor using the graphical resistance calculator. Also, remember that the LED needs to be plugged in the right way (hint - the long leg goes to the positive side of the circuit).
  • 33. www.karkhana.club 33Make Things with Arduino – Karkhana Makerspace© Want to organise Training Program in your campus: Contact Us: +91-93371951963 / +91-9348182664 Courses we offer: 1. Internet of Things 2. Machine Learning 3. Data Science 4. Emebdded Systems 5. Python 6. Robotics 7. Raspberry Pi 8. Image Processing 9. Android Application Design 10. MATLAB 11. Data Structure and Algorithm
  • 34. www.karkhana.club 34Make Things with Arduino – Karkhana Makerspace©
  • 35. www.karkhana.club 35Make Things with Arduino – Karkhana Makerspace© Chapter 1 Getting Started The purpose of this book is to get you started on the road to creating things using micro-controllers. We will discuss only enough electronics for you to make the circuits, and only enough programming for you to get started. The focus will be on your making things. It is my hope that as you go through this book you will be flooded with ideas of things that you can make. So let’s get going... The first question we’ll start with is: 1.1 What is a Microcontroller? Wikipedia says: A micro-controller is a small computer on a single integrated circuit containing a processor core, memory, and programmable input/ output peripherals The important part for us is that amicro-controller contains the processor (which all computers have) and memory, and some input/output pins that you can control.
  • 36. www.karkhana.club 36Make Things with Arduino – Karkhana Makerspace© (often called GPIO - General Purpose Input Output Pins). 1. Introduction i) Arduino is an open-source electronics prototyping platform based on flexible, easy-to use hardware and software. ii) It’s intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments. iii) Arduino can sense the environment by receiving input from a variety of sensors
  • 37. www.karkhana.club 37Make Things with Arduino – Karkhana Makerspace© and can affect its surroundings by controlling lights, motors, and other actuators. iv) The microcontroller on the board is programmed using the Arduino programming language and the Arduino Development Environment. v) Arduino projects can be stand-alone, or they can communicate with software running on a computer. vi) There are plenty of other microcontrollers available. So you may be asking, why choose the Arduino? Arduino really simplifies the process of building projects on a microcontroller making it a great platform for amateurs. vii) You can easily start working on one with no previous electronics experience. In addition to Arduino’s simplicity, it is also inexpensive, cross-platform and open source. The Arduino is based on Atmel’s ATMEGA8 and ATMEGA168 microcontrollers. The plans for the
  • 38. www.karkhana.club 38Make Things with Arduino – Karkhana Makerspace© modules are published under a Creative Commons license, so experienced hobbyists and professionals can make their own version of the Arduino, extending it and improving it. Why Arduino? Thanks to its simple and accessible user experience, Arduino has been used in thousands of different projects and applications. The Arduino software is easy-to-use for beginners, yet flexible enough for advanced users.  Inexpensive - Arduino boards are relatively inexpensive compared to other microcontroller platforms. The least expensive version of the Arduino module can be assembled by hand, and even the pre-assembled Arduino modules cost less than $50  Cross-platform - The Arduino Software (IDE) runs on Windows, Macintosh OSX, and Linux operating systems. Most microcontroller systems are limited to Windows.
  • 39. www.karkhana.club 39Make Things with Arduino – Karkhana Makerspace©  Simple, clear programming environment - The Arduino Software (IDE) is easy-to-use for beginners, yet flexible enough for advanced users to take advantage of as well. For teachers, it's conveniently based on the Processing programming environment, so students learning to program in that environment will be familiar with how the Arduino IDE works.  Open source and extensible software - The Arduino software is published as open source tools, available for extension by experienced programmers. The language can be expanded through C++ libraries, and people wanting to understand the technical details can make the leap from Arduino to the AVR C programming language on which it's based. Similarly, you can add AVR-C code directly into your Arduino programs if you want to.  Open source and extensible hardware - The plans of the Arduino boards are published under a Creative Commons license, so experienced circuit designers can make their own version of the module, extending it and improving it. Even relatively inexperienced users can build the breadboard version of the module in order to understand how it works and save money.
  • 40. www.karkhana.club 40Make Things with Arduino – Karkhana Makerspace© What Can You Do With an Arduino? There is a lot you can do with an Arduino. An Arduino can basically do anything by interfacing sensors with a computer. This would allow you to take any sensor and have any action applied with the readings. For example (in one of our projects) we will read the level of light in a room and adjust an LED’s brightness to react based on that input. This of course is a simple example of what you can do with an Arduino. A more complicated example would be to read from multiple sensors and use that data to affect other outputs. Think of the possibility of wiring your house with all sorts of different sensors (photocells, oxygen sensors, thermometers) and having it adjust your blinds, air conditioner and furnace and make your house a more comfortable place. Hackers have used Arduinos to create some amazing electronics projects.
  • 41. www.karkhana.club 41Make Things with Arduino – Karkhana Makerspace© Things like: • Robots • Breathalyzers • Remote controlled cars • 3d printers • Video games • Home automation systems • Million More ....
  • 42. www.karkhana.club 42Make Things with Arduino – Karkhana Makerspace© What Is Inside an Arduino?
  • 43. www.karkhana.club 43Make Things with Arduino – Karkhana Makerspace© Although there are many different types of Arduino boards available, this manual focuses on the Arduino Uno. This is the most popular Arduino board around. So what makes this thing tick? Here are the specifications: • Processor: 16 Mhz ATmega328 • Flash memory: 32 KB • Ram: 2kb • Operating Voltage: 5V • Input Voltage: 7-12 V • Number of analog inputs: 6 • Number of digital I/O: 14 (6 of them pwm) The specs may seem meager compared to your desktop computer, but remember that the Arduino is an embedded device. We have a lot less to process than your desktop. Another wonderful feature of the Arduino is the ability to use what are called “Shields”. Although we will not be covering shields in this manual, an Arduino shield will give you crazy functionality like you wouldn’t believe. Check out this list of some really cool Arduino shields to take your projects to the next level.
  • 44. www.karkhana.club 44Make Things with Arduino – Karkhana Makerspace© The Integrated Development Environment (IDE) You use the Arduino IDE on your computer (picture following) to create, open, and change sketches (Arduino calls programs “sketches”. We will use the two words interchangeably in this book.). Sketches
  • 45. www.karkhana.club 45Make Things with Arduino – Karkhana Makerspace© define what the boardwill do. You can either use the buttons along the top of the IDE or the menu items. Our First Circuit Before we get to the programming, let’s connect an LED. LED stands for Light Emitting Diode. If you connect the LED directly to power and ground, too much current will go through the diode and destroy it. To keep that from happening we will use a resistor to limit the current. You can think of a resistor like a water pipe. The higher the value of the resistor is like using a smaller pipe that lets less electricity “flow” through. This is not technically correct, but it is close enough for this book. We will use a 330 Ohm (Ohm is often shown as !) resistor (Resistance is measured in ohms. A 330! resistor will have color bands: Orange-Orange-Brown)It doesn’t matter which way you plug in a resistor. The two leads (sometimes called “legs”) of an LED are called an anode and a cathode. The anode is the longer lead. IMPORTANT: IF YOU PLUG IT IN BACKWARDS, IT WILL NOT WORK. (But it won’t be damaged, either. Don’t worry).
  • 46. www.karkhana.club 46Make Things with Arduino – Karkhana Makerspace© Our First Program Now let’s write a program to control the LED. Each program must contain at least two functions. A function is a series of programming statements that can be called by name.  setup() which is called once when the program starts.  loop() which is called repetitively over and over again as long as the Arduino has power. 1. Simplest Program void setup() { } void loop() { }
  • 47. www.karkhana.club 47Make Things with Arduino – Karkhana Makerspace© Blinking of LED // the setup function runs once when you press reset or power the board void setup() { // initialize digital pin LED_BUILTIN as an output. pinMode(13, OUTPUT); } // the loop function runs over and over again forever void loop() { digitalWrite (13, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite (13, LOW); //turn the LED off by making the voltage LOW delay(1000); // wait for a second }
  • 48. www.karkhana.club 48Make Things with Arduino – Karkhana Makerspace©
  • 49. www.karkhana.club 49Make Things with Arduino – Karkhana Makerspace© Projects To Do : Do it yourself. Led pattern a) 2leds b) 4leds c) 8leds a) Forward pattern b) Backward pattern c) Even numbers leds/odd numbers leds THINKING? Join our hands-on training courses. To know more visit us at http://www.karkhana.club/
  • 50. www.karkhana.club 50Make Things with Arduino – Karkhana Makerspace© RGB LED Their are two type of RGB led: i) Common Cathode ii) Common Anode
  • 51. www.karkhana.club 51Make Things with Arduino – Karkhana Makerspace© For Common Cathode:
  • 52. www.karkhana.club 52Make Things with Arduino – Karkhana Makerspace©
  • 53. www.karkhana.club 53Make Things with Arduino – Karkhana Makerspace© Code: void setup() { pinMode(1,OUTPUT); pinMode(2,OUTPUT); pinMode(3,OUTPUT); } void loop() { digitalWrite(1,HIGH); delay(1000); digitalWrite(1,LOW); delay(1000); digitalWrite(2,HIGH); delay(1000); digitalWrite(2,LOW); delay(1000); digitalWrite(3,HIGH); delay(1000); digitalWrite(3,LOW); }
  • 54. www.karkhana.club 54Make Things with Arduino – Karkhana Makerspace© For Common Anode:
  • 55. www.karkhana.club 55Make Things with Arduino – Karkhana Makerspace© Code: void setup() { pinMode(1,OUTPUT); pinMode(2,OUTPUT); pinMode(3,OUTPUT); } void loop() { digitalWrite(1,LOW); delay(1000); digitalWrite(1,HIGH); delay(1000); digitalWrite(2,LOW); delay(1000); digitalWrite(2,HIGH); delay(1000); digitalWrite(3,LOW); delay(1000); digitalWrite(3,HIGH); }
  • 56. www.karkhana.club 56Make Things with Arduino – Karkhana Makerspace© Matrix of LED
  • 57. www.karkhana.club 57Make Things with Arduino – Karkhana Makerspace© Code: // the setup routine runs once when you press reset: void setup() { // initialize the digital pin as an output. pinMode(0, OUTPUT); pinMode(1, OUTPUT); pinMode(2, OUTPUT); pinMode(3, OUTPUT); } // the loop routine runs over and over again forever: void loop() { digitalWrite(0, HIGH); digitalWrite(1, LOW); digitalWrite(2, LOW); digitalWrite(3, HIGH); delay(100); digitalWrite(0, LOW); digitalWrite(1, HIGH); digitalWrite(2, HIGH); digitalWrite(3, LOW); delay(100); } Now apply your own logic and try to generate your own patterns.
  • 58. www.karkhana.club 58Make Things with Arduino – Karkhana Makerspace© Their are LEDs inside the seven segment dispaly. Try to make your own seven segment. Need more help. Visit : http://karkhanaindia.blogspot.in
  • 59. www.karkhana.club 59Make Things with Arduino – Karkhana Makerspace© Push Button What is a pushbutton? A device designed to close or open an electric circuit when a button or knob is depressed, and to return to a normal position when it is released.
  • 60. www.karkhana.club 60Make Things with Arduino – Karkhana Makerspace© How to interface pushbutton to arduino? Since now we are well acquainted with LED’s let us learn how to control the switching using a push button. A push button is used to get control of the circuit. Components Required  Resistors 2Nos. 330ohms,10k(recommended)  Pushbutton 1No.  LED 1No. Standard red LED  Arduino UNO  Breadboard
  • 61. www.karkhana.club 61Make Things with Arduino – Karkhana Makerspace© Now dump the code given below int d=2; // chose the pin which you have connected to the output of push button void setup() { pinMode(2,INPUT); pinMode(13,OUTPUT); } void loop() { d=digitalRead(2); if(d==0) {
  • 62. www.karkhana.club 62Make Things with Arduino – Karkhana Makerspace© digitalWrite(13,HIGH); } else { digitalWrite(13,LOW); } } Now the control is in your hands whenever you will press the button the led will be ON and when you release it, LED will go OFF. You can alter the control like: https://youtu.be/DlaVtHpsrJs Here when we press the button LED goes ON and when we press it again it goes OFF. For the code of the above video mail us at : hello@karkhana.club I hope you are having fun, try connecting multiple switches with multiple LEDs.
  • 63. www.karkhana.club 63Make Things with Arduino – Karkhana Makerspace©  A pull-up resistor condition. When the switch is connected to ground and one end of the resistor is connected to VCC.
  • 64. www.karkhana.club 64Make Things with Arduino – Karkhana Makerspace©  Pull down resistor condition. When one end of the switch is connected to Vcc and the resistor is connected to ground. When you use these conditions while coding just remembers when you press the switch, one will give output as 0 and the other will give output as 1. Do it yourself Logic gates i) And gate ii) Or gate iii) Not gate
  • 65. www.karkhana.club 65Make Things with Arduino – Karkhana Makerspace© Seven Segment Display A 7 SEGMENT DISPLAY consists of 8 LEDs and 10 pins,2 common pins are shorted and supplied with 5 volts from Arduino through a resistor and other 8 pins are connected to digital and analog pins. 7 Segment Display can act as a substitute for LCDs if we want to display numbers.
  • 66. www.karkhana.club 66Make Things with Arduino – Karkhana Makerspace© Shown below is the internal architecture of a 7 segment display. There are two types of LED 7-segment display  Common cathode (CC)  Common anode (CA) In CC type the cathode of all the LEDs is connected together and similarly in CA type.
  • 67. www.karkhana.club 67Make Things with Arduino – Karkhana Makerspace© In CC type we have to ground the common cathode pin and power up segments to illuminate it, the reverse happens for CA types. Here we have to power up the common anode pin and provide ground to segments according to our requirements of illuminations. How to interface a 7 segment display with Arduino? Now let’s interface the 7 SEGMENT DISPLAY. Components Required  Arduino Uno 1No.  7 Segment Display 1No.  Resistors 1No. 100 ohms  Connecting Wires  Breadboard
  • 68. www.karkhana.club 68Make Things with Arduino – Karkhana Makerspace© The below code can be used to display digits from Zero to Nine. void setup() { pinMode(2,OUTPUT); pinMode(3,OUTPUT); pinMode(4,OUTPUT); pinMode(5,OUTPUT); pinMode(6,OUTPUT); pinMode(7,OUTPUT); pinMode(8,OUTPUT); pinMode(9,OUTPUT); digitalWrite(2,HIGH); digitalWrite(3,HIGH); digitalWrite(4,HIGH); digitalWrite(5,HIGH); digitalWrite(6,HIGH); digitalWrite(7,HIGH); digitalWrite(8,HIGH); digitalWrite(9,HIGH); }
  • 69. www.karkhana.club 69Make Things with Arduino – Karkhana Makerspace© void loop() { // ZERO digitalWrite(2,LOW); digitalWrite(3,HIGH); digitalWrite(4,LOW); digitalWrite(5,LOW); digitalWrite(6,LOW); digitalWrite(7,LOW); digitalWrite(8,LOW); digitalWrite(9,LOW); delay(1000); // Zero off digitalWrite(2,HIGH); digitalWrite(3,HIGH); digitalWrite(4,HIGH); digitalWrite(5,HIGH); digitalWrite(6,HIGH); digitalWrite(7,HIGH); digitalWrite(8,HIGH); digitalWrite(9,HIGH); delay(1000); // ONE digitalWrite(4,LOW); digitalWrite(6,LOW);
  • 70. www.karkhana.club 70Make Things with Arduino – Karkhana Makerspace© delay(1000); //1 off digitalWrite(4,HIGH); digitalWrite(6,HIGH); delay(1000); //2 0N digitalWrite(2,LOW); digitalWrite(3,LOW); digitalWrite(5,LOW); digitalWrite(6,LOW); digitalWrite(7,LOW); delay(1000); //2 0ff digitalWrite(2,HIGH); digitalWrite(3,HIGH); digitalWrite(4,HIGH); digitalWrite(5,HIGH); digitalWrite(6,HIGH); digitalWrite(7,HIGH); digitalWrite(8,HIGH); digitalWrite(9,HIGH); delay(1000); //3 0n
  • 71. www.karkhana.club 71Make Things with Arduino – Karkhana Makerspace© digitalWrite(2,LOW); digitalWrite(3,LOW); digitalWrite(5,LOW); digitalWrite(7,LOW); digitalWrite(8,LOW); delay(1000); //3 0ff digitalWrite(2,HIGH); digitalWrite(3,HIGH); digitalWrite(5,HIGH); digitalWrite(7,HIGH); digitalWrite(8,HIGH); delay(1000); //4 on digitalWrite(3,LOW);
  • 72. www.karkhana.club 72Make Things with Arduino – Karkhana Makerspace©  You can also use IC 7446 which is a BCD to 7 segment decoder by which you can display all your digits with the combination of four inputs.Connect the IC as shown below.
  • 73. www.karkhana.club 73Make Things with Arduino – Karkhana Makerspace© A Buzzer (or Piezo Speaker) An electrical device that makes a buzzing noise and is used for signalling. For this you will need:  Arduino uno  Breadboard  Buzzer / piezo speaker  100 Ohm resistor (optional)
  • 74. www.karkhana.club 74Make Things with Arduino – Karkhana Makerspace© Code void setup() { pinMode(7, OUTPUT); // Set buzzer - pin 7 as an output } void loop() { digitalWrite(7, HIGH); // buzzer will on delay(1000); // buzz for 1 sec digitalWrite(7,LOW); // buzzer will off delay(1000); // off for 1 sec }
  • 75. www.karkhana.club 75Make Things with Arduino – Karkhana Makerspace© Buzzer With Push Button For this you will need:  Arduino uno  Breadboard  Buzzer / piezo speaker  220 Ohm resistor -2 no.  Push button
  • 76. www.karkhana.club 76Make Things with Arduino – Karkhana Makerspace© Code int d=2; // chose the pin which you have connected to the output of push button void setup() { pinMode(2,INPUT); pinMode(13,OUTPUT); } void loop() { d=digitalRead(2); if(d==0) { digitalWrite(13,HIGH); } else { digitalWrite(13,LOW); } }
  • 77. www.karkhana.club 77Make Things with Arduino – Karkhana Makerspace© IR Sensor A sensor is a device which detects or measures a physical property and records, indicates or otherwise responds to it. Digital sensors give us output in the form of HIGH or LOW signal. When it detects a phenomenon it gives a HIGH output else a LOW output signal. Few examples of digital sensors are-IR Sensors, Digital Sound Sensors, Digital Temperature Sensors etc. We will interface an Infrared Sensor module.
  • 78. www.karkhana.club 78Make Things with Arduino – Karkhana Makerspace© i) Working on an IR sensor. ii) It basically works as an obstacle detector. iii) Let us learn how to interface an IR (infrared) sensor. Components required:  IR sensor module 1No.  Arduino UNO 1No  Connecting wires.  Breadboard.  LED
  • 79. www.karkhana.club 79Make Things with Arduino – Karkhana Makerspace© TASK 1 : Can You Design The Circuit By Code. Code int d; void setup() { pinMode(12, OUTPUT); pinMode(16, INPUT); } void loop() { d = digitalRead(16); if (d == LOW) { digitalWrite(12, HIGH); } else { digitalWrite(12, LOW); } } Thinking? . Visit : http://www.karkhana.club/
  • 80. www.karkhana.club 80Make Things with Arduino – Karkhana Makerspace© LCD (Liquid Crystal Display) An LCD screen is an electronic display module having a flat panel display or we can say it’s an electronically modulated optical device that uses the light modulating properties of liquid crystals.
  • 81. www.karkhana.club 81Make Things with Arduino – Karkhana Makerspace© How to interface an LCD (liquid crystal display) with ARDUINO ? We will interface a 16x2(16 columns and 2 rows) LCD. Other variations are also available like 8x1,10x2 etc. It is having a wide range of applications; they are also preferred over 7-segment display as they are cheap, easily programmable and also have the leverage to display special characters.
  • 82. www.karkhana.club 82Make Things with Arduino – Karkhana Makerspace© Now let us interface Components Required  16x2 LCD 1No.  Resistor 560ohms 1No.  Potentiometer 10k 1No.  Arduino UNO 1No.  Few connecting wires  Breadboard Follow the image below for circuit connection reference.
  • 83. www.karkhana.club 83Make Things with Arduino – Karkhana Makerspace© After making the circuit dump the code given below. #include<LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { lcd.begin(16, 2); } void loop() { lcd.setCursor(0,0); lcd.print("WELCOME TO"); lcd.setCursor(2,1); lcd.print("SUDOLEARN TECH"); } The potentiometer can be used to control the contrast of your display. You can use an LCD to display the output of your projects instead of showing them in the serial monitor, providing a display to the system will make your system independent and interactive.
  • 84. www.karkhana.club 84Make Things with Arduino – Karkhana Makerspace©  Data is transferred in 4 bits to the pins D4-D7.  LCD has its own controller named Hitachi HD44780 LCD controller. Task : i) Hello word ii) Multiplication of 2,3,4,5,6,7,8,9 iii) Passwords (using switch) iv) Game (football , gun) Thinking? Visit : http://karkhanaindia.blogspot.in
  • 85. www.karkhana.club 85Make Things with Arduino – Karkhana Makerspace© Sensors LDR (Light Dependent Resistor) A light dependent resistor (LDR) or a photo resistor is a device whose resistivity is a function of the incident electromagnetic radiation. Hence, they are light sensitive devices. They are also called as photo conductors, photo conductive cell or simply photocells.
  • 86. www.karkhana.club 86Make Things with Arduino – Karkhana Makerspace© This is simple arduino project; turn on LED when it's dark and turn off when is light. Hardware Required :  Arduino Uno  LED  LDR (photoresistor)  220 and 10k ohm resistors  Wires  Breadboard  Led
  • 87. www.karkhana.club 87Make Things with Arduino – Karkhana Makerspace© Code const int ledPin = 13; const int ldrPin = A0; void setup() { pinMode(ledPin, OUTPUT); pinMode(ldrPin, INPUT); } void loop() { int ldrStatus = analogRead(ldrPin); if (ldrStatus <=300) { digitalWrite(ledPin, HIGH); } else { digitalWrite(ledPin, LOW); } } Try it yourself: 1. Do same thing with tempaerture sensor (LM35)
  • 88. www.karkhana.club 88Make Things with Arduino – Karkhana Makerspace© Ultrasonic sensor An Ultrasonic sensor is a device that can measure the distance to an object by using sound waves. It measures distance by sending out a sound wave at a specific frequency and listening for that sound wave to bounce back. By recording the elapsed time between the sound wave being generated and the sound wave bouncing back, it is possible to calculate the distance between the sonar sensor and the object.
  • 89. www.karkhana.club 89Make Things with Arduino – Karkhana Makerspace© The HC-SR04 Ultrasonic Module has 4 pins, Ground, VCC, Trig and Echo. The Ground and the VCC pins of the module needs to be connected to the Ground and the 5 volts pins on the Arduino Board respectively and the trig and echo pins to any Digital I/O pin on the Arduino Board.
  • 90. www.karkhana.club 90Make Things with Arduino – Karkhana Makerspace© Parts List - Arduino Board - Ultrasonic Sensor HC-SR04 - Buzzer - LED - 220ohm Resistor - Breadboard and Jump Wires
  • 91. www.karkhana.club 91Make Things with Arduino – Karkhana Makerspace© Code Descriptions: - First you have to define the Trig and Echo pins. In this case they are the pins number 9 and 10 on the Arduino Board and they are named trigPin and echoPin. Then you need a Long variable, named “duration” for the travel time that you will get from the sensor and an integer variable for the distance. - In the setup you have to define the trigPin as an output and the echoPin as an Input and also start the serial communication for showing the results on the serial monitor. - If the object is 10 cm away from the sensor, and the speed of the sound is 340 m/s or 0.034 cm/µs the sound wave will need to travel about 294 u seconds. But what you will get from the Echo pin will be double that number because the sound wave needs to travel forward and bounce backward. So in order to get the distance in cm we need to multiply the received travel time value from the echo pin by 0.034 and divide it by 2.
  • 92. www.karkhana.club 92Make Things with Arduino – Karkhana Makerspace© Get the code : defines pins numbers const int trigPin = 9; const int echoPin = 10; const int buzzer = 11; const int ledPin = 13; long duration; int distance; int safetyDistance; void setup() { pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output pinMode(echoPin, INPUT); // Sets the echoPin as an Input pinMode(buzzer, OUTPUT); pinMode(ledPin, OUTPUT); Serial.begin(9600); // Starts the serial communication }
  • 93. www.karkhana.club 93Make Things with Arduino – Karkhana Makerspace© void loop() { // Clears the trigPin digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); //Calculating the distance distance= duration*0.034/2; safetyDistance = distance; if (safetyDistance <= 5){ digitalWrite(buzzer, HIGH); digitalWrite(ledPin, HIGH); } else{ digitalWrite(buzzer, LOW); digitalWrite(ledPin, LOW); } // Prints the distance on the Serial Monitor Serial.print("Distance: "); Serial.println(distance); }
  • 94. www.karkhana.club 94Make Things with Arduino – Karkhana Makerspace© LED Brightness Control Hardware Required  Arduino or Genuino Board  LED  220 ohm resistor Circuit Connect the 220 ohm current limiting resistor to digital pin 9, with an LED in series. The long, positive leg (the anode) of the LED should be connected to the output from the resistor, with the shorter, negative leg (the cathode) connected to ground. Code it yourself ! Hint : analogWrite(3, x); // Range of x = 0-255 Analog Output Pin on Arduino Uno/Nano/Mini – 3,5,6,9,10 & 11
  • 95. www.karkhana.club 95Make Things with Arduino – Karkhana Makerspace© Schematic
  • 96. www.karkhana.club 96Make Things with Arduino – Karkhana Makerspace©