Home Page | Language Reference (extended) | SD Reference | Libraries | Comparison | Changes
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.
Robot.analogRead(port)
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)
int : 0 to 1023
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.).
#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
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.