Arduino I/O
HELLO!
I am Nourhan Mansour
- Team leader at BreakInPoInT
- Head of embedded systems 2
branch at BreakInPoInT
You can find me at:
- m.me/nourhan.mansour2
- [email protected]
What will we do in the
next 2 hours?
▹ What is I/O?
▹ Digital I/O 3
▹ Analog I/O
▹ Practice!
1. What’s I/O?
Let’s start with the first set
of slides
Arduino boards
5
6
“
inputs and outputs on the
Arduino are what allow
you to connect sensors,
actuators, and other ICs
to the Arduino .
7
Examples
On I/O 8
Simple
I/O Circuit
9
simulation
2. Digital I/O
What is a digital signal?
A digital signal is any
signal that takes only
two values. 11
Usually referred to as
High and Low
It could be -5v (low) and
+5v (High)
Or 0v (low) and 5v (High)
“
Please note that a signal
is considered high if
supplied volt is 3v or
higher
And considered low if
supplied volt is 2v or less.
The area between 2 & 3 is
undefined behaviour.
12
Digital inputs
The simplest question Sources of digital
to answer from the real inputs:
world sensing depends 13
on True or False
- Push buttons
For example: Is the door - Switches
open? - Digital Sensors
Then you can determine
the answer with a switch
for example
What’s the difference between
switches and push buttons?
14
“
Switch: is a binary device with
on - off position.
● You can toggle between
them.
Push btn: is a binary device
with momentary on position
and reverts back to off once
released.
● You can’t toggle between
them
15
Interfacing of buttons
16
17
How to switch on internal res?
To enable it, we pass the INPUT PULLUP constant as the second
argument to pinMode():
pinMode(pin, INPUT PULLUP)
To disable it, we pass the constant INPUT instead:
pinMode(pin, INPUT)
Caution: don’t use internal pull-up res if you need a specific value.
18
Digital outputs
Digital output is used to Sources of digital
turn something on or off outputs:
19
- LEDs
- Seven Segments
- Buzzer
Interfacing of LEDs
20
How to calculate
resistance value?
- Avg current of an led
= 14mA
- LED voltage = 2V
- Output voltage of
arduino = 5V 21
- From Ohm’s law
𝚫V=IR
- R = 𝚫v/I
- R = (5-2)/(14*10^3)
=214
- So we can use 220
or 330
Now..
Let’s Place your screenshot here
Code!
22
.
● Blinking LED example
23
● Toggle LED with switch
24
3. Analog I/O
What’s an analog Signal?
An analog signal is any
continuous signal for
which the time-varying
feature (variable) of the
26
signal is a representation
of some other time
varying quantity.
Ie.. infinite Value
between any two values.
Analog inputs
An analog input converts a Sources of analog inputs:
voltage level into a digital
value that can be stored 27
and processed in a - POT
computer. - LDR
- Temperature Sensor
There are a multitude of
sensors available which
convert things like
temperature, pressure, etc.
into voltages.
Voltage divider
A voltage divider is a
simple circuit which
turns a large voltage into
a smaller one. Using just
two series resistors and
28
an input voltage, we can
create an output voltage
that is a fraction of the
input.
POT
- A small sized electronic component
whose res can be adjusted manually.
29
- Increasing or Decreasing the value of
res controls the amount of current
flowing in a circuit.
LDR
- LDR: Light dependant resistor
30
- Basically it’s a resistor that its value varies
depending on light intensity.
- The most common type of LDR has a
resistance that falls with an increase in
the light intensity falling upon the device
Now..
Let’s Place your screenshot here
Code!
31
.
● POT Example
32
33
● Task
○ Traffic light:
Using 3 Leds (red, green, yellow) create appropriate
traffic light with different delay times for go and stop.
○ bright or dark?
Using and LDR set the appropriate light intensity of a
LED so it’s off when it’s very bright and fully on when
it’s completely dark.
● Resources
Simply Arduino
Arduino IO (pdf)
Arduino pins description
Arduino playlist
أردوﯾﻧو ﺑﺎﻟﻌرﺑﻲ
Arduino documentation
THANKS!
Any questions?
36