Home Page | Language Reference (extended) | SD Reference | 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 ) ;
}

Robot Control Board

Robot Motor Board

See also


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.