Download Print this page

Sparkfun Electronics RedBot Getting Started page 12

Advertisement

Incoming data is not reliable above 38400bps. Data transmission still works at higher speeds.
Since the incoming data reception shares an interrupt with the sensors on the board, incoming
data may be missed if other inputs are in use. In particular, incoming serial data may interfere
with bump sensor detection or encoder counts, and incoming encoder data and bump sensing
may interfere with serial data reception.
Motor Functions
The RedBotMotors class within the library provides control over all basic motor functionality. You
should find it very easy to control your robot's motion using this command set.
language:cpp
RedBotMotors();
The constructor for the class, which is used to create a class object that can be referred to later,
accepts no parameters. It will automatically configure all the peripherals and I/O lines you need to
drive the motors. For example, creating an instance of the the RedBotMotors named motor
RedBotMotors motor;
will allow you to call all of the other functions from that class. Such as
motor.drive(255);
Now, let's go over some of the functions that live within that class.
void drive(int speed);
void rightDrive(int speed);
void leftDrive(int speed);
The three drive commands cause the motors to start turning.
(approximately) equal speeds;
important; positive speeds go forward, negative speeds go backwards. The range of speeds is from
0-255, although speeds below about 75 may not provide enough torque to start the motor turning. If
you want very slow motion, try starting at a higher speed, then turning the speed down a bit.
void pivot(int speed);
Pivot turns the robot on its axis by spinning one motor one way and the other the opposite direction.
Positive values correspond to anti-clockwise rotation; negative values to clockwise rotation.
void stop();
void rightStop();
void leftStop();
These commands discontinue the PWM output to one or both motors. The motors will continue to
coast for a short time after this command is issued; if you need to stop quickly, use...
void brake();
void rightBrake();
void leftBrake();
and
rightDrive()
leftDrive()
Page 12 of 19
starts both motors at
drive()
activate their appropriate motors. Sign is

Advertisement

loading
Need help?

Need help?

Do you have a question about the RedBot and is the answer not in the manual?