Skip to main content
code formatting, removed intro
Source Link

This is really late, but i had this same struggle.

On the mega, you'd read the pins with PINE.

So your code in PinA would change to:

reading = PINE & 0b00110000;

if(reading == 0b00110000 && aFlag)

{ encoderPos --; bFlag = 0; aFlag = 0; } else if (reading == 0b00010000) bFlag = 1;

reading = PINE & 0b00110000;

  if(reading == 0b00110000 && aFlag) 

  {  encoderPos --;
    bFlag = 0;
    aFlag = 0;
  }
  else if (reading == 0b00010000) bFlag = 1;

I found a great discussion talking about the masking required here: https://forum.arduino.cc/index.php?topic=561741.0

This is really late, but i had this same struggle.

On the mega, you'd read the pins with PINE.

So your code in PinA would change to:

reading = PINE & 0b00110000;

if(reading == 0b00110000 && aFlag)

{ encoderPos --; bFlag = 0; aFlag = 0; } else if (reading == 0b00010000) bFlag = 1;

I found a great discussion talking about the masking required here: https://forum.arduino.cc/index.php?topic=561741.0

On the mega, you'd read the pins with PINE.

So your code in PinA would change to:

reading = PINE & 0b00110000;

  if(reading == 0b00110000 && aFlag) 

  {  encoderPos --;
    bFlag = 0;
    aFlag = 0;
  }
  else if (reading == 0b00010000) bFlag = 1;

I found a great discussion talking about the masking required here: https://forum.arduino.cc/index.php?topic=561741.0

Source Link

This is really late, but i had this same struggle.

On the mega, you'd read the pins with PINE.

So your code in PinA would change to:

reading = PINE & 0b00110000;

if(reading == 0b00110000 && aFlag)

{ encoderPos --; bFlag = 0; aFlag = 0; } else if (reading == 0b00010000) bFlag = 1;

I found a great discussion talking about the masking required here: https://forum.arduino.cc/index.php?topic=561741.0