Skip to content

Commit

Permalink
Tried to get encoder to work
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateo-S committed Mar 22, 2019
1 parent d1ea5f5 commit 6cfee9d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions motorTest/motorTest.ino
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ boolean completedRotation = false;
int currPositive = 0;
int currNegative = 0;
int currDifference = 0;
int armatureRotations = 174;

int i = 0;

Expand All @@ -37,7 +38,7 @@ void loop() {

void rotate(int r) {
int endCount=PULSES_PER_ROTATION*r;
while (i<endCount) {
while (i/2 >= armatureRotations*r) {
cim.write(180);
currPositive = analogRead(ANALOG_PIN_POSITIVE);
currNegative = analogRead(ANALOG_PIN_NEGATIVE);
Expand All @@ -55,15 +56,15 @@ void rotate(int r) {
}
posOrNeg = false;
}
Serial.println(i);

}


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

}

0 comments on commit 6cfee9d

Please sign in to comment.