Hi all,
I’m writing my first code for an Imp - trying to get a stepper motor rotate through a TC4469. Pin1 and Pin2 of the Imp are used as triggers of the TC4469. But I’m having some code issue, the code is (check the comment for the error):
`
n = 0;
//the bit state of the pins 1 & 2 at each state
const patts = “\x00\x02\x03\x01”;
function turn_step(dir)
{
if (dir) {
if (n == 0) {
n = 3;
} else {
–n;
}
} else {
if (n == 3) {
n = 0;
} else {
++n;
}
}
//the issue is here: “stack overflow, cannot resize stack while in a metamethod” after 2-3 loops
hardware.pin1.write((patts[n] >> 0) & 0x01);
hardware.pin2.write((patts[n] >> 1) & 0x01);
// Schedule the next state change
imp.wakeup(0.1, turn_step(dir));
}
hardware.pin1.configure(DIGITAL_OUT);
hardware.pin2.configure(DIGITAL_OUT);
// Register with the server
imp.configure(“Stepper Rotate”, [], []);
// Start rotating CW
turn_step(1);
`
Where is the mistake? also, could someone explain me the difference in the configuration of the pins as DIGITAL_OUT vs. DIGITAL_OUT_OD_PULLUP?
Thank you!