Lesson 4 Analog Input
Lesson 4 Analog Input
TOPIC OUTLINE
Operating Voltage: 5V
Real projects. Real learning.
Why Arduino?
Status Bar
Console
Real projects. Real learning.
ARDUINO PLATFORM
STATUS
BOARDS / CONNECTION
OVERVIEW
In this lesson, we will use a variable resistor (a
potentiometer), we will read its value using one analog input
of an Arduino board and we change the blink rate of the built-
in LED accordingly. The resistor’s analog value is read as a
voltage because this is how the analog inputs work.
Where:
R – high resistance
R – low resistance
Real projects. Real learning.
LESSON 4: ANALOG INPUT
Specification
Product Name: Potentiometer
Resistance Value: 10kΩ
Hardware Required
10kΩ potentiometer
USB Cable
UNO R3
Breadboard
Jumper wires
Value = analogRead(pin);
//sets ‘value’ equal to ‘pin’
Note: Analog pins unlike digital ones, do not need to be first declared as INPUT
nor OUTPUT.
Real projects. Real learning.
Syntax:
Serial.begin(rate)
Opens serial port and sets the baud rate for serial data transmission.
void setup()
{
Serial.begin(9600); //opens serial port
//sets data rate to 9600bps
}
Note: When using serial communication, digital pins 0 (RX) and 1 (TX) cannot be
used at the same time.
Real projects. Real learning.
Syntax:
Serial.println(data)
Prints data to the serial port, followed by an automatic carriage return and line
feed. This command takes the same form as Serial.print(), but is easier for
reading data on the Serial Monitor.
Connection Diagram