Reference.AnalogRead History

Hide minor edits - Show changes to markup

September 12, 2012, at 01:10 AM by Scott Fitzgerald -
Changed line 23 from:
 [@
to:
Changed lines 38-39 from:

@]

to:
September 12, 2012, at 01:10 AM by Scott Fitzgerald -
Changed lines 42-43 from:
to:
February 01, 2010, at 07:47 PM by David A. Mellis -
Changed lines 5-8 from:

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)

Changed line 41 from:
to:
Deleted line 42:
March 17, 2009, at 12:07 PM by Paul Badger -
Changed line 43 from:
to:
February 21, 2009, at 10:22 PM by David A. Mellis -
Changed lines 42-43 from:
to:
February 21, 2009, at 10:18 PM by David A. Mellis -
Changed lines 17-18 from:

int

to:

int (0 to 1023)

February 21, 2009, at 10:18 PM by David A. Mellis -
Changed lines 1-2 from:

int analogRead(pin)

to:

analogRead()

February 21, 2009, at 10:18 PM by David A. Mellis -
Added lines 9-11:

Syntax

analogRead(pin)

Changed lines 17-18 from:

An integer value in the range of 0 to 1023.

to:

int

Changed lines 41-43 from:
to:
June 18, 2008, at 04:41 PM by David A. Mellis -
Changed lines 5-6 from:

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)

February 14, 2008, at 04:29 AM by David A. Mellis -
Changed line 38 from:
  • Description of the analog input pins
to:
January 31, 2008, at 09:34 PM by David A. Mellis -
Added lines 13-15:

Returns

An integer value in the range of 0 to 1023.

Changed lines 17-21 from:

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

Returns

An 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 HIGH or LOW depending if the input at analog pin is higher than a certain threshold.

Deleted lines 38-39:
January 26, 2008, at 12:09 AM by David A. Mellis - removing duplicate link
Deleted line 50:
January 26, 2008, at 12:09 AM by David A. Mellis -
Changed lines 5-8 from:

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)

January 11, 2008, at 07:06 PM by David A. Mellis -
Added line 52:
  • Description of the analog input pins
Deleted lines 57-58:
December 22, 2007, at 02:42 PM by Paul Badger -
Changed line 32 from:

Serial.begin(9600); // setup serial

to:
  Serial.begin(9600);          //  setup serial
Changed lines 38-39 from:
  Serial.begin(9600);             // debug value
to:
  Serial.println(val);             // debug value
December 22, 2007, at 02:41 PM by Paul Badger -
Changed lines 5-6 from:

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.

Added line 32:

Serial.begin(9600); // setup serial

Added lines 38-39:
  Serial.begin(9600);             // debug value
November 04, 2007, at 05:27 AM by Paul Badger -
Changed lines 5-6 from:

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.

November 04, 2007, at 05:25 AM by Paul Badger -
Changed lines 5-6 from:

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.

November 04, 2007, at 05:21 AM by Paul Badger -
Changed lines 5-6 from:

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.

November 04, 2007, at 05:06 AM by Paul Badger -
Added line 47:
November 04, 2007, at 05:05 AM by Paul Badger -
Changed lines 11-12 from:

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.

to:

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.

Changed lines 21-24 from:

int ledPin = 13; // LED connected to digital pin 13 int analogPin = 3; // potentiometer wiper (middle terminal) connected to analog pin 3 // outside leads to ground and +5V int val = 0; // variable to store the read value

to:

int ledPin = 13; // LED connected to digital pin 13 int analogPin = 3; // potentiometer wiper (middle terminal) connected to analog pin 3

                       // outside leads to ground and +5V

int val = 0; // variable to store the value read

Changed line 34 from:
  val = analogRead(analogPin);   // read the input pin
to:
  val = analogRead(analogPin);    // read the input pin
Changed line 38 from:
    digitalWrite(ledPin, LOW);   // sets the LED off
to:
    digitalWrite(ledPin, LOW);    // sets the LED off
November 04, 2007, at 05:03 AM by Paul Badger -
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 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 INPUT nor OUTPUT

This function returns

to:

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

Returns

Changed lines 22-23 from:

int analogPin = 3; // potentiometer connected to analog pin 3

to:

int analogPin = 3; // potentiometer wiper (middle terminal) connected to analog pin 3 // outside leads to ground and +5V

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.

Changed lines 14-15 from:

An integer value in the range of 0 to 1024.

to:

An integer value in the range of 0 to 1023.

July 13, 2006, at 01:32 PM by Massimo Banzi -
Changed line 34 from:
    digitalWrite(ledPin, LOW);   // sets the LED on
to:
    digitalWrite(ledPin, LOW);   // sets the LED off
January 13, 2006, at 12:38 AM by 82.186.237.10 -
Changed lines 1-3 from:

analogRead

What it does

to:

int analogRead(pin)

Description

Changed line 7 from:

What parametres does it take

to:

Parameters

Added lines 47-48:
December 03, 2005, at 08:58 PM by 213.140.6.103 -
Changed line 18 from:

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

to:

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

Changed line 20 from:

int val = 0; // variable to store the read value

to:

int val = 0; // variable to store the read value

Changed line 25 from:
  pinMode(ledPin, OUTPUT);      // sets the digital pin 13 as output
to:
  pinMode(ledPin, OUTPUT);   // sets the digital pin 13 as output
Changed line 32 from:
    digitalWrite(ledPin, HIGH);    // sets the LED on
to:
    digitalWrite(ledPin, HIGH);   // sets the LED on
Changed line 34 from:
    digitalWrite(ledPin, LOW);    // sets the LED on
to:
    digitalWrite(ledPin, LOW);   // sets the LED on
December 03, 2005, at 08:57 PM by 213.140.6.103 -
Added lines 3-46:

What it does

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.

What parametres does it take

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.

Note

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

This function returns

An integer value in the range of 0 to 1024.

Example

 
int ledPin = 13; // LED connected to digital pin 13
int analogPin = 3;   // potentiometer connected to analog pin 3
int val = 0;     // variable to store the read value
int threshold = 512;   // threshold 

void setup()
{
  pinMode(ledPin, OUTPUT);      // sets the digital pin 13 as output
}

void loop()
{
  val = analogRead(analogPin);   // read the input pin
  if (val >= threshold) {
    digitalWrite(ledPin, HIGH);    // sets the LED on
  } else {
    digitalWrite(ledPin, LOW);    // sets the LED on
  }
}

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

See also

November 27, 2005, at 05:42 PM by 81.154.199.248 -
Added lines 1-2:

analogRead

Share