Hardware Reference
In-Depth Information
stops. The speedRight parameter works in exactly the same way. This function
does not return any data.
To instruct both motors to stop, use motorsStop() :
Robot.motorsStop();
This function takes no parameters and does not return any data. It instructs
both motors to stop immediately.
Turning can be achieved by varying the speed of rotation of the left and right
motors. By varying the speed of each motor, you can achieve rotation, but the
Arduino Robot goes a step further and has an embedded compass that can be
used for greater accuracy. To tell the Arduino Robot to turn by a specii c amount
of degrees, use turn() :
Robot.turn(degrees);
This function takes one parameter, an int , and accepted values are between
-180 to 180. Negative values make the robot turn left; positive values make the
robot turn right. Entering a value of zero has no effect. This function uses the
on-board compass to get a bearing to magnetic north and then turns the robot
by a specii c number of degrees, verii ed by the compass. To make the robot
turn to a specii c heading, use pointTo() :
Robot.pointTo(degrees);
Like turn() , pointTo() uses the compass to get its bearings, but instead of
turning a specii c amount of degrees, it tells the Arduino Robot to face a par-
ticular heading. It takes one parameter, degrees , which is the heading to face,
where 0 is north, east is 90, south is 180, and west is 270.
The robot automatically decides if it should turn left or right, whichever is
the shortest turn.
Sensor Reading
For robots to function correctly, they require multiple sensors. They need to
know where they are and how they can interact with the world. You can add
additional sensors to the Arduino Robot, but it already comes with a few sen-
sors to get you started.
As seen previously, the Arduino Robot can be told to face in a specii c direc-
tion, using the compass. You can also read the value of the compass using
compassRead() :
result = Robot.compassRead();
This function returns an int ; the degrees of rotation from magnetic north.
 
Search WWH ::




Custom Search