ARDUINO – WEEK 5
Lecture Layout
Quiz 1 (10%)
Potentiometer
Analog to Digital Conversion (ADC 10 bit)
Hands-on Project 4: Potentiometer operated LED (7%)
2
QUIZ! – Instructions
Log in to the PC using your account
Open BLACKBOARD and click on PYP032
Click on the folder “QUIZ!” and Arduino Quiz 1
Read the instructions before the Quiz
No.Of Questions: 10 (Multiple choice)
Duration: 10 min
Grade: 10%
No backtracking 3
Potentiometer (pot)
A variable resistor with three pins
Two of the pins are connected to the ends of a fixed resistor
The middle pin, moves across the resistor, dividing it into two halves.
When the external sides of the potentiometer are connected to voltage and
ground, the middle leg will give the difference in voltage as you turn the knob.
Analog vs digital signals
5V
0V
5V
0V
Analog to digital conversion (ADC)
Arduino has a built in 10-bit analog-to-
digital converter (ADC)
Need to convert analog signals to digital
for processing.
Digital signal depends on the resolution of the
analog-to-digital converter (ADC).
A 10-bit system will have 1,023 points of
resolution.
Analog to digital conversion (ADC)
Arduino translates an analog input voltage into a number that ranges from 0 - 1,023.
Digital voltages are translated into a number that ranges from 0 – 255.
0 255
Hands-on Project 3: Analog Input (5%)
Read analog input from the physical world using a
potentiometer and control the blink rate of an LED.
Use the serial monitor to watch how the voltage changes.
When it’s connected with 5V across its two outer pins +5V
The middle pin outputs a voltage between 0 and 5V,
depending on the position of the knob Analog Input
GND
In this way, it can be used as a “voltage divider”.
Circuit schematic
The left side of the schematic is the same
as the previous circuit.
We’re adding a potentiometer to control
the blink rate of the LED.
We’re running 5V across the outer pins of
the pot. The middle pin of the
potentiometer will be connected to analog
input pin 0.
Note: All analog pins on the Arduino are
INPUT pins. Digital pins can be INPUT or
OUTPUT pins.
Design it!
220 Ω
Create
The sketch
int
Integers are your primary data-type for number storage
An int stores a 16-bit (2-byte) value [(2^15) – 1]
Range of -32,768 to 32,767
https://www.arduino.cc/reference/en/language/variables/data-types/int/
analogRead
(pin)
Reads the value from the specified analog pin.
Arduino boards contain 10-bit ADC.
Map input voltages between 0-5V into values between 0 and 1023.
Usable pins A0 to A5.
https://www.arduino.cc/reference/en/language/functions/analog-io/analogread/ 13