Reads the value from the specified analog pin. The Arduino board contains a 6 channel (8 channels on the Mini and Nano), 10-bit analog to digital converter. This means that it will map input voltages between 0 and 5 volts into integer values between 0 and 1023. This yields a resolution between readings of: 5 volts / 1024 units or, .0049 volts (4.9 mV) per unit.

It takes about 100 us (0.0001 s) to read an analog input, so the maximum reading rate is about 10,000 times a second.

to:

Reads the value from the specified analog pin. The Arduino board contains a 6 channel (8 channels on the Mini and Nano, 16 on the Mega), 10-bit analog to digital converter. This means that it will map input voltages between 0 and 5 volts into integer values between 0 and 1023. This yields a resolution between readings of: 5 volts / 1024 units or, .0049 volts (4.9 mV) per unit. The input range and resolution can be changed using [[analogReference]]().

It takes about 100 microseconds (0.0001 s) to read an analog input, so the maximum reading rate is about 10,000 times a second.

Changed lines 14-15 from:

pin: the number of the analog input pin to read from (0 to 5 on most boards, 0 to 7 on the Mini and Nano)

to:

pin: the number of the analog input pin to read from (0 to 5 on most boards, 0 to 7 on the Mini and Nano, 0 to 15 on the Mega)

Reads the value from the specified analog pin. The Arduino board contains a 6 channel (8 channels on the Mini), 10-bit analog to digital converter. This means that it will map input voltages between 0 and 5 volts into integer values between 0 and 1023. This yields a resolution between readings of: 5 volts / 1024 units or, .0049 volts (4.9 mV) per unit.

to:

Reads the value from the specified analog pin. The Arduino board contains a 6 channel (8 channels on the Mini and Nano), 10-bit analog to digital converter. This means that it will map input voltages between 0 and 5 volts into integer values between 0 and 1023. This yields a resolution between readings of: 5 volts / 1024 units or, .0049 volts (4.9 mV) per unit.

Changed lines 11-12 from:

pin: the number of the analog input pin to read from (0 to 5 on most boards, 0 to 7 on the Mini)

to:

pin: the number of the analog input pin to read from (0 to 5 on most boards, 0 to 7 on the Mini and Nano)

Analog pins default to inputs and unlike digital ones, do not need to be declared as [[Constants|INPUT]] nor [[Constants|OUTPUT]]

!!!!ReturnsAn integer value in the range of 0 to 1023.

to:

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.).

Deleted line 20:

int ledPin = 13; // LED connected to digital pin 13

Changed lines 24-25 from:

int threshold = 512; // threshold

to:

Deleted line 26:

pinMode(ledPin, OUTPUT); // sets the digital pin 13 as output

Deleted lines 33-38:

if (val >= threshold) { digitalWrite(ledPin, HIGH); // sets the LED on } else { digitalWrite(ledPin, LOW); // sets the LED off }

Deleted lines 36-38:

Sets pin 13 to [[Constants|HIGH]] or [[Constants|LOW]] depending if the input at analog pin is higher than a certain threshold.

Reads the value from the specified analog pin. The Arduino board contains a 6 channel (8 channels on the mini), 10-bit analog to digital converter. This means that it will map input voltages between 0 and 5 volts into integer values between 0 and 1023. This yields a resolution between readings of: 5 volts / 1024 units or, .0049 volts (4.9 mV) per A/D unit.

It takes about 100 us (.0001 s) to read an analog input, so the maximum reading rate is about 10000 times a second.

to:

Reads the value from the specified analog pin. The Arduino board contains a 6 channel (8 channels on the Mini), 10-bit analog to digital converter. This means that it will map input voltages between 0 and 5 volts into integer values between 0 and 1023. This yields a resolution between readings of: 5 volts / 1024 units or, .0049 volts (4.9 mV) per unit.

It takes about 100 us (0.0001 s) to read an analog input, so the maximum reading rate is about 10,000 times a second.

Changed lines 11-14 from:

int pin

AnalogRead() accepts one integer specifying the number of the pin to read. Values between 0 and 5 are valid on most boards, and between 0 and 7 on the mini.

to:

pin: the number of the analog input pin to read from (0 to 5 on most boards, 0 to 7 on the Mini)

Reads the value from the specified analog pin. The Arduino board contains a 6 channel (8 channels on the mini), 10-bit analog to digital converter. This means that it will map input voltages between 0 and 5 volts into integer values between 0 and 1023. This yields a resolution between readings of: 5 volts / 1024 units or, .0049 volts (4.9 mV) per A/D unit.

to:

Reads the value from the specified analog pin. The Arduino board contains a 6 channel (8 channels on the mini), 10-bit analog to digital converter. This means that it will map input voltages between 0 and 5 volts into integer values between 0 and 1023. This yields a resolution between readings of: 5 volts / 1024 units or, .0049 volts (4.9 mV) per A/D unit.

Reads the value from the specified analog pin. The Arduino board contains a 6 channel (8 channels on the mini), 10-bit analog to digital converter. This means that it will map input voltages between 0 and 5 volts into integer values between 0 and 1023. This yields a resolution between readings of 5 volts / 1024 units or .0049 volts (4.9 mV) per A/D unit.

to:

Reads the value from the specified analog pin. The Arduino board contains a 6 channel (8 channels on the mini), 10-bit analog to digital converter. This means that it will map input voltages between 0 and 5 volts into integer values between 0 and 1023. This yields a resolution between readings of: 5 volts / 1024 units or, .0049 volts (4.9 mV) per A/D unit.

Reads the value from the specified analog pin. The Arduino board contains a 6 channel (8 channels on the mini), 10-bit analog to digital converter. This means that it will map input voltages between 0 and 5 volts into integer values between 0 and 1023. This yields a resolution between readings of 5 / 1024 or .0049 volts (4.9 mV) per A/D unit.

to:

Reads the value from the specified analog pin. The Arduino board contains a 6 channel (8 channels on the mini), 10-bit analog to digital converter. This means that it will map input voltages between 0 and 5 volts into integer values between 0 and 1023. This yields a resolution between readings of 5 volts / 1024 units or .0049 volts (4.9 mV) per A/D unit.

Reads the value from the specified analog pin. The Arduino board contains a 6 channel (8 channels on the mini), 10-bit analog to digital converter. This means that it will map input voltages between 0 and 5 volts into integer values between 0 and 1023. This yields a resolution between readings of 5 / 1024 or .0049 volts (4.9 mV) per A/D unit.

to:

Reads the value from the specified analog pin. The Arduino board contains a 6 channel (8 channels on the mini), 10-bit analog to digital converter. This means that it will map input voltages between 0 and 5 volts into integer values between 0 and 1023. This yields a resolution between readings of 5 / 1024 or .0049 volts (4.9 mV) per A/D unit.

It takes about 100 us (.0001 s) to read an analog input, so the maximum reading rate is about 10000 times a second.

Reads the value from a specified analog pin, the Arduino board makes a 10-bit analog to digital conversion. This means that it will map input voltages between 0 and 5 volts into integer values between 0 and 1023.

to:

Reads the value from the specified analog pin. The Arduino board contains a 6 channel (8 channels on the mini), 10-bit analog to digital converter. This means that it will map input voltages between 0 and 5 volts into integer values between 0 and 1023. This yields a resolution between readings of 5 / 1024 or .0049 volts (4.9 mV) per A/D unit.

Changed lines 8-9 from:

You need to specify the number of the pin you want to read. It has to be one of the analog pins of the board, thus it should be a number between 0 and 5. It could also be a variable representing one value in that range.

to:

int pin

AnalogRead() accepts one int parameter specifing the number of the pin to read. Values between 0 and 5 are valid on most boards, and between 0 and 7 on the mini.

Changed lines 14-16 from:

Analog pins unlike digital ones, do not need to be declared as [[Constants|INPUT]] nor [[Constants|OUTPUT]]

!!!!This function returns

to:

Analog pins default to inputs and unlike digital ones, do not need to be declared as [[Constants|INPUT]] nor [[Constants|OUTPUT]]

September 27, 2007, at 05:05 AM
by David A. Mellis - changing 1024 to 1023

Changed lines 4-6 from:

Reads the value from a specified analog pin, the Arduino board makes a 10-bit analog to digital conversion. This means that it will map input voltages between 0 and 5 volts into integer values between 0 and 1024.

to:

Reads the value from a specified analog pin, the Arduino board makes a 10-bit analog to digital conversion. This means that it will map input voltages between 0 and 5 volts into integer values between 0 and 1023.

!!!!What it doesReads the value from a specified analog pin, the Arduino board makes a 10-bit analog to digital conversion. This means that it will map input voltages between 0 and 5 volts into integer values between 0 and 1024.

!!!!What parametres does it takeYou need to specify the number of the pin you want to read. It has to be one of the analog pins of the board, thus it should be a number between 0 and 5. It could also be a variable representing one value in that range.

!!!!NoteAnalog pins unlike digital ones, do not need to be declared as [[Constants|INPUT]] nor [[Constants|OUTPUT]]