controlling a servo from a ping

I am using an arduino an rc servo and a ping sensor. I have managed to get the servo to run and can adjust both direction, speed and pause, I have also managed to get the ping to display distance in the serial monitor. My question is does anyone know of someone who has used these two together and can direct me to some code. I would prefer not to use a library just yet because this is a learning exercise for me.

Thanks, Notty

Hi Notty. If it's a learning exercise then why not tinker with the two pieces of code you have and see if you can combine them. A library would make the servo code easier because it avoids the need for constant refreshes. But you can read the ping sensor every 20 milliseconds or so to calculate a distance and send a pulse to the servo.

Try it and see what happens. If you get stuck, post your code here and I am sure you will get help.

Have fun!