Hardware Reference
In-Depth Information
The Arduino Robot contains TinkerKit connectors, both on the control board
and on the motor board. Most of these ports can be read as both digital and
analog, depending on the function call. Two functions can be called:
digit-
alRead()
and
analogRead()
.
DigitalResult = Robot.digitalRead(port);
AnalogResult = Robot.analogRead(port);
The
port
parameter is a constant: the ID of the TinkerKit port to use. Accepted
values are TK0-TK3, TKD0-TKD5, and B_TK1 to B_TK4. TK4 and TK5 are digital
inputs only.
digitalRead()
returns either
TRUE
or
FALSE
.
analogRead()
returns
integer values between 0 and 1023.
NOTE
Before reading the value of a TinkerKit port, make sure that a device is con-
nected. Reading the value of a port where no device is present can result in unex-
pected results.
Of course, some TinkerKit ports are not used only for input, and the control
board can also set TinkerKit outputs. To write digital output, use
digitalWrite()
:
digitalWrite(port, value);
The
value
parameter is the value to write, either
HIGH
or
LOW
. The
port
param-
eter is the TinkerKit port, one of TKD0-TKD5, B_TK1-B_TK4, or LED1 (an LED
located on the control board).
To write an analog value, use
analogWrite()
:
Robot.analogWrite(port, value);
The
value
parameter is the analog value to write, ranging from 0 to 255. The
output is not true analog; it is created using PWM, as with most Arduino analog
outputs. The port value is the TinkerKit port to use; it can be used only on TKD4
and cannot be used at the same time as TK0 through TK7.
Personalizing Your Robot
I love all my Arduinos, but there is something even more lovable about com-
puters that can follow you around. Just like a pet, it deserves a name and some
personal information. This information can be stored in EEPROM and retrieved
through special functions.
To give the robot a name, use
robotNameWrite()
:
Robot.robotNameWrite(name);
The
name
parameter is a string and can be up to eight characters. The data
will be stored into EEPROM and can be retrieved with
robotNameRead()
:
Search WWH ::
Custom Search