0% found this document useful (0 votes)
208 views21 pages

Lesson 4 Analog Input

This document discusses using an Arduino board to read the value of a variable resistor or potentiometer and change the blink rate of the onboard LED accordingly. It explains that the potentiometer's resistance controls the voltage, which is read by the analog input between values of 0-1023. Turning the potentiometer shaft changes the resistances and voltage, allowing the Arduino to detect input and adjust the LED blink rate based on the analog reading value. Code examples are provided to configure the serial port, read analog input, and print values to serial monitor for monitoring potentiometer position.

Uploaded by

brett
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
208 views21 pages

Lesson 4 Analog Input

This document discusses using an Arduino board to read the value of a variable resistor or potentiometer and change the blink rate of the onboard LED accordingly. It explains that the potentiometer's resistance controls the voltage, which is read by the analog input between values of 0-1023. Turning the potentiometer shaft changes the resistances and voltage, allowing the Arduino to detect input and adjust the LED blink rate based on the analog reading value. Code examples are provided to configure the serial port, read analog input, and print values to serial monitor for monitoring potentiometer position.

Uploaded by

brett
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

Real projects. Real learning.

TOPIC OUTLINE

Real projects. Real learning.


Real projects. Real learning.
Real projects. Real learning.
WHAT IS ARDUINO?
Arduino is an open-source physical computing platform based on a simple
microcontroller board, and a development environment for writing software
for the board.

Real projects. Real learning.


ARDUINO ATMEGA 2560

Digital I/O: 54 Pins


Analog Output: 15 Pins

Flash Memory: 256kB


Write/Erase: 10,000 times

CPU Speed: 16MHz

Analog Input: 16 Pins

Operating Voltage: 5V
Real projects. Real learning.
Why Arduino?

Extensible Hardware and Software

Real projects. Real learning.


DIGITAL AND ANALOG SIGNAL

Analog Signal --- information is


translated into electric pulses of
varying amplitude. 

Digital Signal --- information is into


binary format (zero or one) where each
bit is representative of two distinct
amplitudes.

Real projects. Real learning.


ARDUINO PLATFORM
Functions:
• Verify
• Upload
• New
• Open
• Save
Text Editor

Status Bar
Console
Real projects. Real learning.
ARDUINO PLATFORM

WORKING FILE SKETCH

STATUS

BOARDS / CONNECTION

Real projects. Real learning.


ARDUINO PLATFORM --- BASIC FUNCTION

Real projects. Real learning.


Real projects. Real learning.
LESSON 4: ANALOG INPUT

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.

Real projects. Real learning.


Basic Types of Potentiometer

1. Single Turn – used for gain, treble,


base control in amplifier, brightness,
contrast in TV.
2. Multiple Turn – used for precise
setting of resistance.
3. Trimmer – used for one time
resistance adjustment.

Real projects. Real learning.


Application

Usually, used for volume control for


audio appliances and varying voltage,
current, light intensity, motor speed
etc.

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

Real projects. Real learning.


Syntax:
analogRead(pin)
Reads the value from a specified analog pin with a 10-bit resolution. This
function only works on the analog pins (0 – 5). The resulting integer values range
from 0 to 1023.

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.

Serial.prinln(analogvalue); //sends the value of


//’analogvalue’

Real projects. Real learning.


LESSON 5: FADING

Connection Diagram

Real projects. Real learning.


Syntax:
int inpin = 0;
int val = 0;
 
void setup() {
Serial.begin(9600);
}
 
void loop() {
val = analogRead(inpin); // read the value of analog pin 0
Serial.println(val); // write the value to the serial port
}

Real projects. Real learning.


LESSON 4: ANALOG INPUT
Application Effect:
By turning the shaft of the potentiometer, you change the amount of resistance
on either side of the center pin (or wiper) of the potentiometer. This changes the
relative resistances between the center pin and the two outside pins, giving you a
different voltage at the analog input. When the shaft is turned all the way in one
direction, there is no resistance between the center pin and the pin connected to
ground. The voltage at the center pin then is 0 volts, and analogRead() returns 0.
When the shaft is turned all the way in the other direction, there is no resistance
between the center pin and t pin connected to +5 volts. The voltage at the center
pin then is 5 volts, and analogRead() returns 1023. In between, analogRead()
returns a number between 0 and 1023 that is proportional to the amount of
voltage being applied to the pin. Real projects. Real learning.

You might also like