Hardware Reference
In-Depth Information
#include <Compass.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <SPI.h>
#include <SquawkSD.h>
#include <EasyTransfer2.h>
Not all these are required. Typically, you need only to include
ArduinoRobot.h
.
To create a sketch for the motor board, add the
Robot_Motor
library in Sketch
➪
Import Library
➪
Robot_Motor. This adds the following
include
declarations:
#include <ArduinoRobotMotorBoard.h>
#include <Multiplexer.h>
#include <EasyTransfer2.h>
#include <LineFollow.h>
Not all these are required. Typically, you need to include only
ArduinoRobotMotorBoard.h
.
Control Board
To use Arduino Robot control board, you must use functions from the
RobotControl
class. The functions are accessed through the object directly, so
there is no need to call the constructor. However, to begin using the Arduino
Robot-specii c functions, you must i rst call
begin()
:
Robot.begin();
begin()
initializes interboard communication, sets variables to their correct
values and other initializations for the Arduino Robot, but does not initialize
the LCD screen or the speaker; other functions exist for those and are explained
later in this chapter in the “LCD Screen” section.
Robotic Controls
The basis of any robot is, of course, movement. The Arduino Robot has an impres-
sive amount of sensors, but its primary function is to move. The motor board
has two independent motors, and although it is the motor board that drives
these motors, the control board can instruct the motor board to perform actions.
To control the motors directly, use
motorsWrite()
:
Robot.motorsWrite(speedLeft, speedRight);
This function takes two parameters: two
int
values. The
speedLeft
variable
instructs the left motor at what speed it should rotate; accepted values range
from -255 and 255. If the value is greater than 0, the motor turns forward. If
the value is negative, the motor turns backward. If the value is zero, the motor
Search WWH ::
Custom Search