Arduino UNO trouble at executing two actions

Hi,

I'm trying to move a servo (with an encoder strip stuck on it) and at the same time I want an encoder reader to count and show in real time the counts on a LCD screen 16x2. This starts to happen when I press the button 'start'. The problem is when the servo is moving, the encoder reader does not count anything or the counting is not correct. Everything has separately proven to work correctly.

Find attached the code,

Thank you!

code.txt (1.23 KB)

I don't think that code will compile. The } on line 39 terminates the loop() function.

Have a look at the demo Several Things at a Time. Note how each function runs very briefly and returns to loop() so the next one can be called. Long running processes are achieved a tiny piece at a time. And there may be dozens of calls to some functions before it is actually time for anything to happen.

...R