Arduino - Advanced I/O Function
In this chapter, we will learn some advanced Input and Output Functions.
analogReference() Function
Configures the reference voltage used for analog input (i.e. the value used as the top of the input range). The options are −- DEFAULT − The default analog reference of 5 volts (on 5V Arduino boards) or 3.3 volts (on 3.3V Arduino boards)
- INTERNAL − An built-in reference, equal to 1.1 volts on the ATmega168 or ATmega328 and 2.56 volts on the ATmega8 (not available on the Arduino Mega)
- INTERNAL1V1 − A built-in 1.1V reference (Arduino Mega only)
- INTERNAL2V56 − A built-in 2.56V reference (Arduino Mega only)
- EXTERNAL − The voltage applied to the AREF pin (0 to 5V only) is used as the reference
analogReference() Function Syntax
analogReference (type);type − can use any type of the follow (DEFAULT, INTERNAL, INTERNAL1V1, INTERNAL2V56, EXTERNAL)
Do not use anything less than 0V or more than 5V for external reference voltage on the AREF pin. If you are using an external reference on the AREF pin, you must set the analog reference to EXTERNAL before calling the analogRead() function. Otherwise, you will short the active reference voltage (internally generated) and the AREF pin, possibly damaging the microcontroller on your Arduino board.
Alternatively, you can connect the external reference voltage to the AREF pin through a 5K resistor, allowing you to switch between external and internal reference voltages.
Note that the resistor will alter the voltage that is used as the reference because there is an internal 32K resistor on the AREF pin. The two act as a voltage divider. For example, 2.5V applied through the resistor will yield 2.5 * 32 / (32 + 5) = ~2.2V at the AREF pin.
Example
int analogPin = 3;// potentiometer wiper (middle terminal) connected to analog pin 3
int val = 0; // variable to store the read value
void setup() {
Serial.begin(9600); // setup serial
analogReference(EXTERNAL); // the voltage applied to the AREF pin (0 to 5V only)
// is used as the reference.
}
void loop() {
val = analogRead(analogPin); // read the input pin
Serial.println(val); // debug value
}
arduino projects for beginners
arduino projects with code
arduino projects for kids
arduino projects book
arduino projects for engineering students
arduino projects ideas
arduino projects for dummies
arduino projects for beginners pdf
arduino projects advanced
arduino projects amazon
arduino projects art
arduino projects app
arduino projects agriculture
arduino projects and codes
arduino projects alarm system
arduino projects automotive
the arduino projects book
arduino projects beginner
arduino projects book code
arduino projects book free download
arduino projects beginner kit
arduino projects based on agriculture
arduino projects biomedical
arduino projects blinking led
raspberry pi 3 b arduino projects
arduino projects code
arduino projects cool
arduino projects c++
arduino projects car
arduino projects covid
arduino projects covid 19
arduino projects circuit digest
arduino projects course
arduino cc projects
arduino c programming projects
arduino projects download
arduino projects diy
arduino projects drone
arduino projects diagram
arduino projects distance sensor
arduino projects digital clock
arduino projects door lock
arduino projects dc motor control
d arduino
arduino projects easy
arduino projects examples
arduino projects electronics hub
arduino projects engineering
arduino projects easy to make
arduino projects ebook
arduino projects explained
arduino projects elevator
arduino e bike projects
arduino projects for high school students
arduino projects for beginners with code
arduino projects for adults
f() arduino
arduino projects github
arduino projects games
arduino projects garden
arduino projects greenhouse
arduino projects gps tracker
arduino projects gsm module
arduino projects guitar
arduino projects gyroscope
arduino project hub
arduino projects home automation
arduino projects ham radio
arduino project handbook
arduino project help