Arduino

Reference Language | Libraries | Comparison | Changes

Robot

## analogRead()

#### Description

Reads the value from the specified port on the robot. The ports are exposed on the robot as TinkerKit connectors.

The board has a 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.

#### Syntax

Robot.analogRead(port)

#### Parameters

port: TK0 to TK7 (found on the Control Board), TKD0 to TKD5 (found on the Control Board), or B_TK1 to B_TK4 (found on the motor Board)

#### Returns

int : 0 to 1023

#### Note

If the input port is not connected to anything, the value returned by Robot.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.).

#### Examples

#include <ArduinoRobot.h>
void setup(){
Robot.begin();
Serial.begin(9600);
}
void loop(){
Serial.println(Robot.analogRead(TK0)); //Print the value on port TK0
delay(100);
}
[Get Code]

Robot Control Board

Robot Motor Board

#### See also

- digitalRead()
- digitalWrite()
- analogWrite()

Reference Home

Corrections, suggestions, and new documentation should be posted to the Forum.

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

### Share

### This link has expired.
Please re-subscribe to our Newsletters.

### Subscribe to our Newsletters

Email

Please enter a valid email to subscribe

Arduino Newsletter
Arduino Store Newsletter

### Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy

###### Newsletter

- ©2015 Arduino
- Copyright Notice
- Contact us
- Careers