GPS and sonar issue. GPS slow everything down

Hi all,

I have a - most probably extreme noob question: I am trying to read data from 2 sonars. This works fine. Connecting just a GPS using the TinyGPS code works okay as well. However if I put the 2 Sonars and GPS together the GPS delays the readings of the sonars.

Does this make sense? And if so, how to prevent this from happening? I understand that the sonar had a very low refresh rate compare to the GPS.

How do I deal with something like this?

Thank you!

The problem is not the GPS or the "sonar". The problem is your code ..........


how to prevent this from happening?

Design your sketch so that it doesn't happen. If you have two or more activities that need to be controlled independently the best way to do this is to control each activity using non-blocking code so that none of your code needs to stop (block) waiting for something to happen. The blink without delay example sketch provides a very simple demonstration of the technique. Robin2 posted a more complete and better-implemented example in the forum a few weeks ago.