Can you post all your code?

I see that you have a NEXT command inside a subroutine. Where is FOR?

Also, are you getting good results from your serial output?

Ioannis