Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a Motor Class #1

Open
theDataSmith opened this issue Nov 29, 2016 · 2 comments
Open

Create a Motor Class #1

theDataSmith opened this issue Nov 29, 2016 · 2 comments
Assignees

Comments

@theDataSmith
Copy link
Contributor

theDataSmith commented Nov 29, 2016

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.
@Pastyguy
Copy link
Contributor

motor driver used in class
https://www.pololu.com/product/713

@Pastyguy
Copy link
Contributor

sweet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants