I am currently having issues trying to read a serial input signal from an IR receiver while in a timer interrupt loop. From browsing other forum posts, I have concluded that one can’t utilize serial I/O while in a timer interrupt ISR because the ISR works using serial I/O. Is there a solution to be able to look for an IR receiver signal while in an ISR?
My project involves controlling a stepper motor that goes through three different “routines” of rotating CW or CCW for a set number of pulses to actuate a lead screw. The stepper motor routine is selected by the user by using an IR remote to choose which mode to run. When the user presses play on the IR remote, the stepper motor routine starts. I am trying to allow the user to pause/resume the stepper motor routine by using a timer interrupt to look for a push of the pause button while still in the middle of the stepper routine.
I currently have the timer interrupt working to the point where a press of the pause button causes the stepper motor routine to halt, but the Arduino does not look for another press of the play button as it is programmed. Printing to the serial monitor shows me that the program enters my while() loop in the ISR, but skips over the code that looks for the next IR signal.
Attached is my code. Any help with this or suggestions with a better way to accomplish this task is greatly appreciated. This program is being used with a Uno.
Stepper Motor IR Control.doc (34 KB)