Mega analog input questions

Hi im pretty new to the arduino scene...so i have quite a few basic questions id like to ask that hopefully someone has done the same thing im trying to do.

Ive built a wheeled robot consisting of an arduino mega microcontroller a power and relay circuit that i built from scracth to power and control the arduino and 2 24v gear motors. My control circuit which consists of 3 5v relays DPDT that will be controlled by 3 analog output pins one to each relay giving me my forward, reverse and spin. I also have 2 IR diffuse sensors ( ones that read off of any surface up to 11 inches away) they are pretty much either on or off depending on if it see something in its 11 inch range or not.

Here is my question...I want to control the 3 analog output pins based on the front and rear sensor input. Now the sensors are both sinking or sourcing depending on what wires i will be using and they output what ever voltage i use to power them...right now its 12V dc, and they have an operating voltage of 10-30v DC. can i use the analog inputs by sinking the output voltage from the sensors...and if so what is the tolerance on that input voltage...if i need to use an external resistance to bring the voltage down to say 5v DC that is no problem. Thanks

The Arduino doesn't have analog outputs. It has PWM outputs but those would not be of much use with relays. I think you want digital outputs.

The inputs can only deal with Vcc+0.5V and maximum Vcc is 6.0V. To connect your sensors to Arduino inputs you will want to reduce the voltage to Vcc or less.

thanks, yes sorry i was thinking of the pwm outputs...now can they be controlled by those analog inputs?...cause right now i have them sending out the 5v DC to trip tvhe coil on the relay feeding in the 15vdc i have going to the motors, I know everything external to the arduino works fine as i used a simple program to trigger each of the pwm outputs as if they were getting controlled by a sensor.

Unless your relays can turn on an off thousands of times per second you probably don't need a PWM (analogWrite()) output. You should use digitalWrite() to turn the output on (HIGH, anything but zero) and off (LOW, zero).

Yes, you can write a sketch that reads from an analog input (analofRead(pin)) and uses that data to decide what digital outputs to change.