Skip to content

Commit

Permalink
Added changes to motorTEst
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateo-S authored Mar 22, 2019
1 parent 7faf522 commit e3f1251
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions chairmans2019.ino
Original file line number Diff line number Diff line change
Expand Up @@ -329,35 +329,33 @@ unsigned long sumRange(const unsigned long arr[], int ind1, int ind2) {
return sum;
}

void rotate(int r) {
int endCount=PULSES_PER_ROTATION*r;
while (i/2 >= armatureRotations*r) {
void rotate(double r) {
int endCount = PULSES_PER_ROTATION * r;
while (i / 2 >= endCount) {
cim.write(180);
currPositive = analogRead(ANALOG_PIN_POSITIVE);
currNegative = analogRead(ANALOG_PIN_NEGATIVE);
currDifference = (currPositive - currNegative);

if(currDifference > 0){
if(!posOrNeg){
if (currDifference > 0) {
if (!posOrNeg) {
i++;
}
posOrNeg = true;
}
else if (currDifference < 0){
if(posOrNeg){
else if (currDifference < 0) {
if (posOrNeg) {
i++;
}
posOrNeg = false;
}
Serial.println(i);
Serial.println(i);

}

// Stop rotating after r revolutions
i = 0;
cim.write(90);
completedRotation = true;
Serial.println("Stop");
delay(4000);


cim.write(90);
completedRotation = true;
Serial.println("Stop");
delay(4000);

}

0 comments on commit e3f1251

Please sign in to comment.