     then you're going anti-clockwise.
   */
   if (ENCODER_PORT & encoder0PinBMask) {
+    encoder0Pos --;
+  }
+  else {
     encoder0Pos ++;
-  }
-  else {
-    encoder0Pos --;
   }
 }
 


// ENCODER SETUP ---------------------------
// encoder on 2 and 3   // +5 is brown, ground is blue
#define ENCODER_PORT PORTD
const int encoder0PinA = 2;  // white   PORTD BIT 2
const byte encoder0PinAMask = 0x04;
const int encoder0PinB = 3;  // black   PORTD BIT 3

float homingSpeed = 3.0;
bool homed = false;

const int BACKOFF_STEPS = 200; // how many encoder steps to reverse out of endstop (so Zero is this far from the switch)


// MOTOR TIMING/POS
