Serial causing different program results?

Has anyone ever experienced getting different results when outputting different results with the Serial monitor? For example, I was outputting two sets of data to the Serial monitor (one was some calculation in the program and the other was an incremental encoder counter). For some reason, when both are outputted, the encoder counter became negative (which it shouldn't have, 10000%), and when I outputted only the counter, the counter became positive (which is what I exactly programmed). Instances like this are always giving my head big headaches, and I haven't found a possible solution to this problem. Does anyone have any advice?

P.S. This also occurs with motor speeds as well .-.

If its a cheap encoder they seem to suffer from a lot of bounce and it may take you a while to find a decent example and lib to work with.

I had quite a bit of trouble initially. Best bet is as some of the better people say in here write a sketch just for each piece of hardware and make sure you get to understand it before you add those sketches together into your final one.

Seen exactly that issue if I spun the encoder too quickly or had a poor lib that didnt have DEBOUNCE involved.

There’s a good chance it’s a bug in your code. Please post it using code tags (</> button on the toolbar).

Also, if you have Serial.print() statements in an interrupt service routine, you can see such effects.