Skip to content

Commit

Permalink
Rotary encoder values don't go below zero now
Browse files Browse the repository at this point in the history
  • Loading branch information
gniezen committed Sep 2, 2014
1 parent 70c3fd6 commit 2fd03e4
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions ui/ui.ino
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,21 @@ void loop()
newLeft = knobLeft.read();
newRight = knobRight.read();
if (newLeft != positionLeft || newRight != positionRight) {

if(newLeft <= 0) {
newLeft = 0;
knobLeft.write(0);
}
if(newRight <= 0) {
newRight = 0;
knobRight.write(0);
}

sprintf(buff, "%ld,%ld,", newLeft/2, newRight/2);
Serial.println(buff);
positionLeft = newLeft;
positionRight = newRight;
positionRight = newRight;

sprintf(buff, "%ld.%ld", newLeft/2, newRight/2);
Serial.println(buff);
}

//Drive stepper motor
Expand Down

0 comments on commit 2fd03e4

Please sign in to comment.