AnalogRead()

From Microduino Wiki
Revision as of 06:08, 12 August 2016 by Fengfeng (talk) (Created page with "<pre style="color:green"> int analogRead (uint8_t pin) </pre> Read the analog pin Read the analog pin, and return the value in [0-1023]. Each reading will takes 1ms. *''...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
int analogRead (uint8_t pin)  	

Read the analog pin

Read the analog pin, and return the value in [0-1023]. Each reading will takes 1ms.

  • Parameter:

pin Number of the pin

  • Return:

Value during 0 to 1023.

  • Example:
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
}


[Return to Arduino Syntax Manual]