Arduino Function: RobotControl.analogRead

Description

This method 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

The parameter port can be one of the following: *TK0 to TK7 (found on the Control Board) *TKD0 to TKD5 (found on the Control Board) *B_TK1 to B_TK4 (found on the motor Board)

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 

void setup(){
  Robot.begin();
  Serial.begin(9600);
}

void loop(){
  Serial.println(Robot.analogRead(TK0)); //Print the value on port TK0
  delay(100);
}


Based on the reference originally written by Arduino Community,  wiring.org.co and  arduino.cc