Skip to content

Commit

Permalink
Convert all tabs to spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
platisd committed Jan 16, 2017
1 parent c487e7b commit 4951ce2
Show file tree
Hide file tree
Showing 21 changed files with 812 additions and 812 deletions.
42 changes: 21 additions & 21 deletions src/BrushedDCMotor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@ BrushedDCMotor::BrushedDCMotor(){ //represents programmatically the very simple,
}

void BrushedDCMotor::attach(unsigned short forwardPin, unsigned short backwardPin, unsigned short enablePin) {
_forwardPin = forwardPin; //the direction pin that when set to HIGH (and the other to LOW) makes the motor move "forward"
_backwardPin = backwardPin; //the direction pin that when set to HIGH (and the other to LOW) makes the motor move "backward"
_enablePin = enablePin; //the enable pin, that controls the motor's speed
pinMode(_forwardPin, OUTPUT);
pinMode(_backwardPin, OUTPUT);
pinMode(_enablePin, OUTPUT);
_forwardPin = forwardPin; //the direction pin that when set to HIGH (and the other to LOW) makes the motor move "forward"
_backwardPin = backwardPin; //the direction pin that when set to HIGH (and the other to LOW) makes the motor move "backward"
_enablePin = enablePin; //the enable pin, that controls the motor's speed
pinMode(_forwardPin, OUTPUT);
pinMode(_backwardPin, OUTPUT);
pinMode(_enablePin, OUTPUT);
}

void BrushedDCMotor::setDirection(unsigned short direction){ //receives the direction the particular motor should have and sets it accordingly
switch (direction){
case BACKWARD:
digitalWrite(_forwardPin, LOW);
digitalWrite(_backwardPin, HIGH);
break;
case FORWARD:
digitalWrite(_forwardPin, HIGH);
digitalWrite(_backwardPin, LOW);
break;
default: //IDLE
digitalWrite(_forwardPin, LOW);
digitalWrite(_backwardPin, LOW);
break;
}
switch (direction){
case BACKWARD:
digitalWrite(_forwardPin, LOW);
digitalWrite(_backwardPin, HIGH);
break;
case FORWARD:
digitalWrite(_forwardPin, HIGH);
digitalWrite(_backwardPin, LOW);
break;
default: //IDLE
digitalWrite(_forwardPin, LOW);
digitalWrite(_backwardPin, LOW);
break;
}
}

void BrushedDCMotor::setSpeed(unsigned short pwmSpeed){ //receives the speed of the motor as a PWM raw value
analogWrite(_enablePin, pwmSpeed);
analogWrite(_enablePin, pwmSpeed);
}
Loading

0 comments on commit 4951ce2

Please sign in to comment.