Getting servo and sonic range finder to play nice together.

Trying to get a servo to respond in a certain way to a range finder.

My test code for the servo using servo.h works fine.

My test code for the range finder using NewPing works fine.

Put them both together and I get unpredictably weird behavior.

My guess is both libraries may be using timers and interrupts to do there thing and they are interfering with each other? Think that's what's wrong?

Now I also have an Adafruit 16-servo driver board and we'll eventually wire that up to offload the servo work. My guess is that will resolve the issue so this is somewhat of a curiosity question to figure out more about Adruino. Is there anything that will tell which resources a library uses so you know if library X and libary Y both use timer1, they won't play nice in the sandbox together?

(I'm a computer scientist but work in ecommerce software. It's been three decades. It's been three decades since I "banged on the metal" so to speak.

-l2t

My test code for the servo using servo.h works fine.

My test code for the range finder using NewPing works fine.

Both of which you forgot to post.

Don't forget the code tags

It's possible the Newping and Servo libraries are incompatible. If so you could try the ServTimer2 library. I got my copy here.

...R