top of page

07 Working with Analog Pins

analogRead()

Input/Output and Analog/Digital I/O Comparison

Pins in the Arduino controller can be configured as inputs or outputs. Additionally they can be either an analog or digital signal. The following table summarizes this variation and the commands used for each.

Reads the value from the specified analog pin. The RP2040 board contains a 4 channel 12-bit analog to digital converter. This means that it will map input voltages between 0 and 3.33 volts into integer values between 0 and 4095. This yields a resolution between readings of: 3.33 volts / 4095 units or, .00081 volts (0.81 mV) per unit.


On the RP2040, it takes about 2 microseconds (0.000002 s) to read an analog input, so the maximum reading rate is about 500,000 times a second.

analogRead(pin)


pin: the number of the analog input pin to read from (A0 to A3 on RP2040 boards)


Returns

int (0 to 4095)


Note: If the analog input pin is not connected to anything, the value returned by analogRead() will fluctuate based on a number of factors (e.g. the values of the other analog inputs, how close your hand is to the board, etc.).




© 2021 Odyssey Navigator. All rights reserved.

bottom of page