Arduino Uno ADC Tutorial: Measuring Voltage with Analog Signals

Arduino Uno ADC Tutorial: Measuring Voltage with Analog Signals
Performance Parameters① Main control chip: ATmega328P② Digital input/output pins: 14③ PWM pins: 6④ Storage (code space): 32KB⑤ RAM (runtime storage): 2KB; EEPROM (power-off storage): 1KB⑥ Crystal oscillator: 16MHzOnline Simulation: https://wokwi.com/
Arduino Uno Tutorial ①: Installing Arduino IDE
Arduino Uno Tutorial ②: Development Board and LED Test
Arduino Uno Tutorial ③: Button Control LED, with Exercises
Arduino Uno Tutorial ④: Analog Signals, Using ADC to Measure Voltage
(1) Introduction
In practical circuits, the voltage value is often not an exact integer but an analog value with infinite non-repeating decimals. However, computers cannot directly process such analog values, so they need to be converted into digital values. The Arduino Uno achieves this conversion through its built-in ADC.The Arduino UNO has 5 analog pins, A0-A5ADC Working PrincipleVoltage Range: The ADC of Arduino Uno can read voltages in the range of 0 to 5V.Resolution: The ADC of Arduino Uno has a resolution of 10 bits, meaning it can divide the voltage range of 0 to 5V into 1024 (2^10) equal parts. Thus, each part represents a voltage value of 5V/1024.Conversion Process: When an analog voltage is applied to the analog pin of the Arduino Uno, the ADC reads that voltage value and converts it to the nearest equal part. For example, if the voltage is 3V, the ADC will convert it to the nearest integer value, which is 614 (3V/5V×1024≈614.4, rounded to 614).Series Resistor The analog input pins of the Arduino Uno have a fixed reference voltage (usually 5V or 3.3V, depending on the board’s power supply voltage), and its ADC (Analog-to-Digital Converter) has a fixed resolution (usually 10 bits, which can distinguish values between 0 and 1023). If the voltage to be measured exceeds the reference voltage of the Arduino analog input, or if the measured voltage range is too large, direct use may lead to inaccurate measurements or damage to the board. In this case, by connecting one or more resistors in series to divide the voltage, the voltage to be measured can be reduced to a range suitable for Arduino measurement.(2) Program
Arduino Uno ADC Tutorial: Measuring Voltage with Analog Signals
① The analog input range of Arduino Uno (5V) is divided into 1023 units by the ADC (Analog-to-Digital Converter), with each unit corresponding to a voltage value of 5/1024=0.0048875855327468
#define BV 0.0048875855327468
② Define Variables
int v;            // Define the digital value measured by analog (1~1023)
double lv;        // Define the voltage of the measured resistor
int RR = 2;       // Number of resistors
③ The initialization function enables the serial port, with a baud rate of 9600, and sets the A0 port to input mode
void setup() {  Serial.begin(9600);  pinMode(A0,INPUT);}
④ The loop function reads the analog value from the A0 port, saves it to variable v, multiplies variable v by the voltage BV of each ADC part, saves the result to lv, and prints the value of variable lv to the serial port
void loop() {  v = analogRead(A0);  lv = v * BV * 2;             Serial.println(lv);}
⑤ Program
#define BV 0.0048875855327468   // The analog divides 5V into 1023 units——5/1023
int v;                  // Define the digital value measured by analog (1~1023)
double lv;              // Define the voltage of the measured resistor
int RR = 2;             // Number of resistors
void setup() {  Serial.begin(9600);  pinMode(A0,INPUT);
}
void loop() {  v = analogRead(A0);  lv = v * BV * 2;             Serial.println(lv);}
⑥ Experimental Phenomenon
Arduino Uno ADC Tutorial: Measuring Voltage with Analog Signals
To be continued…
END

Apply for Development Board

Arduino Uno ADC Tutorial: Measuring Voltage with Analog Signals

Submission/Promotion/Cooperation/Join Group Please scan to add WeChat
(Please specify your intention, when joining the group please specify city-name-industry position information)
Arduino Uno ADC Tutorial: Measuring Voltage with Analog Signals
Arduino Uno ADC Tutorial: Measuring Voltage with Analog Signals

Leave a Comment

×