> For the complete documentation index, see [llms.txt](https://uvuvlib-documentation.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://uvuvlib-documentation.gitbook.io/docs/reference/api-reference/motor.md).

# Motor

The UvuvLib Motor Class

```cpp
UvuvMotor::UvuvMotor(uint8_t port, bool isReversedArg, Gearing gearRatioArg, pros::motor_gearset_e gearset, 
    UvuvMotor* pairMotorArg, PIDController* pidArg)
```

* **port** - V5 Smart Port number
* **isReversedArg** - Defines direction of the motor spinning. True is reversed, false is foward
* **gearRatioArg** - Gear ratio of the motors mechanism. Accessed by "G\_"
* **gearset** - The PROS motor gearset
* **pairMotorArg** - The motor paired with this motor. For example, leftFront and rightFront motors.
* **pid** - The Built-in PID Controller for the motor

### spinAtVoltage

*Spins the motor at the provided voltage, given that the motor is not disabled*&#x20;

```cpp
void spinAtVoltage(int voltage)
```

**voltage** - An integer between -12000 and 12000. This number determines the voltage that the motor will spin at

### spinJoystick

*Spins the motor in increments of 1/127 of its total power*&#x20;

```cpp
void spinJoystick(int joystickValue)
```

**joystickValue** - An integer between -127 and 127 that determines the power that the motor spins at. This value would be the same one returned by a Joystick, hence the name of the function

### spinPerc

*Spins the motor as a percentage of its total power*

<pre class="language-cpp"><code class="lang-cpp"><strong>void spinPerc(int percent) 
</strong></code></pre>

**percent** - the percentage of the Total Power of the motor. Takes in an integer value between -100 to 100

### spinPercVEXPID

*Uses VEX Built in PID. Spins the motor at the indicated percentage of motor power. (DO NOT USE WITH PID)\[Quasi-Deprecated]*

```cpp
void spinPercVEXPID(int percent)
```

**percent** - the fraction of the Total Power of the motor. Takes in an integer value between -127 to 127

### spinAtRPM

*Spins the motor at the given RPM*

```cpp
void spinAtRPM(int RPM)
```

**RPM** - The Rotations Per Minute you desire the motor to move. Works through the PID Controller, so make sure that you assign one to this motor before using it.

### spinUntilDegree

*Spins the motor around for how many degrees you provide it*

```cpp
void UvuvMotor::spinUntilDegree(int degree, int speedInVoltage)
```

**degree** - the amount of degrees you want the motor to spin

**speedInVoltage** - An integer between -12000 and 12000. This number determines the voltage that the motor will spin at

### spinFor

*Spins the motor for how many seconds you tell it to*

```cpp
void spinFor(float seconds, int speedInVoltage)
```

**seconds** - the amount of timke in seconds that the motor will spin for

**speedInVoltage** - An integer between -12000 and 12000. This number determines the voltage that the motor will spin at

### ~~logMotorPreference~~

*Not yet Implemented*

### set\_zero\_position

*Sets the motor position*

```cpp
void set_zero_position(int position)
```

**position** - Sets the absolute position of this motor to position

### shutDown

*Shuts down the motor*

```cpp
void shutDown()
```

###

### Revive

*Enables the Motor*

```cpp
void revive()
```

###

### isOverheated

*Checks if the motor is overheated, returns True if it is, false if it isn't*

```cpp
bool isOverheated()
```

###

### getIsBroken

*Returns back the **isBroken** param*

```cpp
bool getIsBroken()
```

###

### getRPM

*Returns the Rotations Per Minute that the Bot is doing at the moment*

```cpp
float getRPM()
```

###

### getVoltage

*Returns the voltage in the Motors at the moment*

```cpp
float getVoltage()
```

###

### getEncoderPos

*Gets the Motor Position in degrees.*

```cpp
float getEncoderPos()
```
