Hi Mikistromar,
So your code works fine with Arduino Mini but it doesn't work with Arduino Due. Hmm, as I use to say: Arduino Due is a different monster. Let's talk about the hardware:
Before you try to make the code run (even when it runs OK with your Mini), you should make sure you hardware, in this case, your I/O devices are the right ones for Due.
Question: -Are your stepper motor and encoder designed to operate at 3.3V?
Remember that Due operates at 3.3V and the Mini at 5V. If your answer is yes, so far so good but if you answer is no, you have two options:
- Replace them for 3.3 similar ones.
- Use voltage converter means between them and Due.
Some encoders are pure mechanical but others have chips that depend on the input voltage (3.3V, 5V). Similarly, some step motors operate at 3.3V or 5V. I recommend you to use only 3.3V I/O devices, basically, to protect Due.
Let's talk about software.
Your code is relatively simple but it is not quite clear to me what you want to do with it. It looks like you want to control the step motor with the encoder using interruptions. Am I right? If so, why to migrate from Mini to Due? better time response I guess?
Regarding interrupts, one good news about Due is that you can attach an interrupt function on all its pins.
Continuing with your code, only for debugging purposes, you should use the serial function to determine if your code is running or not.
Anyway, I'd recommend you to start testing your I/O devices and Due using simple example sketches separately. For example, try the example 1 of the Arduino playground (rotary encoder) and see if the encoder counts OK or not. Then you can move to another example with interrupts, etc...and please, keep us posted about your progress. regards!
p