Skip to content

Commit

Permalink
Add move function
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonPucheu committed Mar 14, 2023
1 parent 4160a6e commit a2f9f26
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Motor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ Motor::Motor(uint8_t in1, uint8_t in2, uint8_t pwm, uint8_t offset, uint8_t stan
toMax = iToMax;
}

void Motor::move(int speed)
{
motor.drive((map(speed, fromMin, fromMax, toMin, toMax)));
}

void Motor::forward(int speed)
{
motor.drive((map(speed, fromMin, fromMax, toMin, toMax)));
Expand Down
1 change: 1 addition & 0 deletions src/Motor.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Motor
{
public:
Motor(uint8_t in1, uint8_t in2, uint8_t pwm, uint8_t offset, uint8_t standBy, int iFromMin = 0, int iFromMax = 255, int iToMin = 0, int iToMax = 255);
void move(int speed);
void forward(int speed);
void forward(int speed, int duration);
void backward(int speed);
Expand Down

0 comments on commit a2f9f26

Please sign in to comment.