Functions | |
| int | Motor_SetActive (int index, int state) |
| Sets whether the specified motor is active. | |
| int | Motor_GetActive (int index) |
| Returns the active state of the DC Motor I/O lines. | |
| int | Motor_SetSpeed (int index, int duty) |
| Set the speed of a DC motor. | |
| int | Motor_SetDirection (int index, char forward) |
| Set the direction of a DC motor. | |
| int | Motor_GetSpeed (int index) |
| Read the speed of a DC motor. | |
| int | Motor_GetDirection (int index) |
| Read the direction of a DC motor. | |
Each motor controller is composed of 2 adjacent Digital Outs on the Make Application Board:
Other output devices cannot be used simultaneously - for example, the DigitalOuts cannot be called without first setting overlapping the DC motor I/O lines to inactive.
See the digital out section of the Application Board overview for more details.
| int Motor_GetActive | ( | int | index | ) |
Returns the active state of the DC Motor I/O lines.
| index | An integer specifying which DC Motor (0-3). |
if( Motor_GetActive(0) ) { // Motor 0 is active } else { // Motor 0 is inactive }
| int Motor_GetDirection | ( | int | index | ) |
Read the direction of a DC motor.
| index | An integer specifying which DC Motor (0-3). |
if( Motor_GetDirection(0) ) { // Motor 0 is going forward } else { // Motor 0 is going in reverse }
| int Motor_GetSpeed | ( | int | index | ) |
Read the speed of a DC motor.
| index | An integer specifying which DC Motor (0-3). |
// check the current speed of motor 1 int motor1_speed = Motor_GetSpeed(1);
| int Motor_SetActive | ( | int | index, | |
| int | state | |||
| ) |
Sets whether the specified motor is active.
| index | An integer specifying which Motor (0-3). | |
| state | An integer specifying the availability of the motor's I/O lines - 1 (active) or 0 (inactive). |
// Enable motor 0 Motor_SetActive(0, 1);
| int Motor_SetDirection | ( | int | index, | |
| char | forward | |||
| ) |
Set the direction of a DC motor.
| index | An integer specifying which DC Motor (0-3). | |
| forward | A character specifying direction - 1/non-zero (forward) or 0 (reverse). |
// Set the direction of motor 2 to reverse. Motor_SetDirection(2, 0);
| int Motor_SetSpeed | ( | int | index, | |
| int | duty | |||
| ) |
Set the speed of a DC motor.
| index | An integer specifying which DC Motor (0-3). | |
| duty | An integer (0 - 1023) specifying the speed. |
// Set the speed of motor 3 to %75 Motor_SetSpeed(3, 768);