Reads the value from the specified analog pin. The 86Duino boards contain several channels (6 channels on the Zero and EduCake, 7 on the One), 11-bit analog to digital converter. This means that it will map input voltages between 0 and 3.3 volts into integer values between 0 and 1023 (or 2047 by calling analogReadResolution() to set the 11-bit resolution). This yields a resolution between readings of: 3.3 volts / 1024 units or, .0032 volts (3.2 mV) per unit.

It takes about 15 microseconds (0.000015 s) to read an analog input, so the maximum reading rate is about 66,666 times a second.

In addition, there is no any analog pin on 86Duino PLC, the value getting from analogRead() is not available.




pin: the number of the analog input pin to read from (0 to 5 on the Zero and EduCake, 0 to 6 on the One)


int (0 to 1023 by default)


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

On 86Duino boards, the maximum input voltage of the analog to digital converter is 3.3V and so the user must take care the input voltage on every analog pin. If there is a voltage > 3.3V appearing on any analog pin, the whole analog to digital converter will behave strangely and even be destroyed.


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

void setup()
  Serial.begin(9600);          //  setup serial

void loop()
  val = analogRead(analogPin);    // read the input pin
  Serial.println(val);            // debug value

See also

Tutorial: Analog Input Pins

Language Reference Home

The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.