This repository was archived by the owner on Jun 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
tutorial motors
Tianshu Huang edited this page Oct 7, 2018
·
4 revisions
It's time to make the robot be more than just a brick with an absurdly bright LED.
First, include the relevant files:
#include <RASLib/inc/common.h>
#include <RASLib/inc/motor.h>Then, create the main loop, and declare the motors:
static tMotor *left;
static tMotor *right;
int main() {Next, initialize the motors:
left = InitializeServoMotor(PIN_B6, false);
right = InitializeServoMotor(PIN_B7, true);Note that the second argument can be either true or false; this argument controls the direction.
Finally, set the motor speeds. Motor speed parameters should be a floating point number between -1 and 1, inclusive.
SetMotor(left, 1.0);
SetMotor(right, 1.0);Putting this all together, our code is:
#include <RASLib/inc/common.h>
#include <RASLib/inc/motor.h>
static tMotor *left;
static tMotor *right;
int main() {
left = InitializeServoMotor(PIN_B6, false);
right = InitializeServoMotor(PIN_B7, true);
SetMotor(left, 1.0);
SetMotor(right, 1.0);
}