-
Notifications
You must be signed in to change notification settings - Fork 0
Motors
There are two motor types: LargeMotor, and MediumMotor. When creating a motor, specify a name (It can be anything!) and the port it is connected to. You can then access and operate on that motor.
To define a new motor, write the following in HardwareCreator
new LargeMotor(String name, char port);
new MediumMotor(String name, char port);
Example:
new LargeMotor("armMotor", 'A');If your motor is inverted, you can declare so by adding true to the constructor:
new LargeMotor("armMotor", 'A', true);
To access a motor, call RobotMap.getMotor() with either the name or port:
RobotMap.getMotor("armMotor")
RobotMap.getMotor('A')This will allow you to use the motor as follows:
RobotMap.getMotor("armMotor").forward(1.0);Motors have forward(double speed) and backwards(double speed) commands, as well as drive for degrees or seconds. (Similar to the Mindstorms software).
A motor's speed is always between 0 and 1 when a direction is specified (i.e. motor.forward() ) or between -1 and 1 when no direction is specified (i.e. motor.rotate(speed, degrees, brake) )
The brake boolean at the end of certain functions specify whether the motor should brake or coast. (Again, similar to Mindstorms)
- Overview
- Code Documentation
- Writing our first run
- Setting Up
- Defining hardware
- Writing a basic Motor Control run
- [Adding sensors and waits]
- [Defining Runs]
- Writing our second run
- [Using the chassis]
- [Finishing up]
- [Line follower code example]