-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
This class will represent a single motor. It will send data over three pins to the motor driver. It should have a constructor that takes the numbers (int) of the three pins as arguments and stores them. Those three pins are:
- Forward
- Backward
- PWM
The motor has four modes, depending on which of the forward and backward pins are high/low:
| Forward | Backward | Mode |
|---|---|---|
| LOW | LOW | Coast |
| HIGH | LOW | Forward |
| LOW | HIGH | Backward |
| HIGH | HIGH | Brake |
The PWM pin controls how fast the motor turns when it's in the forward or backward mode.
Needed Arduino functions:
pinMode()
digitalWrite() (for the forward and backward pins)
analogWrite() (for the PWM pin)
The class should have the following public functions
- void setSpeed(float speed)
- Takes a value between -1 and 1, and sets the direction and speed of the motor. -1 for backward, 1 for forward.
- void coast()
- Sets the speed to 0 in coast mode.
- void brake()
- Sets the speed to 0 in brake mode.
Reactions are currently unavailable