Ultrasonic sensor

I am still new in Arduino but I am building an autonomous rover. So I was wondering if anyone can help me to clarify this. Can I use multiple ultrasonic sensors without using servos? Can inuse like 4 or 5 sensors on each side at the same time?

Ultrasonic sensors interfere with each other if triggered at the same time. They need to be triggered and the distance measured sequentially.

You might want to set up various functions to handle what you want. For example write the function for measuring distance. Have separate functions to check front, back, etc. establishing pin values for echo and trig inside function are only used in that function. With 1 sensor you would do a const int trigPin = #; But the pins will change per sensor fo in the check right (for example) establish pin value. You can change it for each function. Use int trigPin = and not const int.
Hope that helps. I have done it. It sounds hard to explain but is actually easy to code.

jremington:
Ultrasonic sensors interfere with each other if triggered at the same time. They need to be triggered and the distance measured sequentially.

i thought that but i was not sure about becuase my first time using but thanks a lot

Outcast923:
You might want to set up various functions to handle what you want. For example write the function for measuring distance. Have separate functions to check front, back, etc. establishing pin values for echo and trig inside function are only used in that function. With 1 sensor you would do a const int trigPin = #; But the pins will change per sensor fo in the check right (for example) establish pin value. You can change it for each function. Use int trigPin = and not const int.
Hope that helps. I have done it. It sounds hard to explain but is actually easy to code.

yeah its kind of complicated to play with this sensors lol
correct me if i am wrong you mean i have to code single ultrasonic sensor
ex.
void setup()
{
leftPin = 3;
rightPin = 10;
or i have to code the if it were like if statement
if this sensor else go to this sensor..

Think of it this way. You want to use several sensors to check distances rather than one sensor and servo. You could set up four function (L,R,F,B) assuming 4 sensors. inside the function you can define echoPin and trigPin and perform whatever distance checking routine.
The benefit on single sensor and servo is that less pins used. If you are using a mega, there are plenty of pins and multiple PWM.

If I knew a bit more about what you want the bot to do, I could probably give you clearer guidance. I can give you a lot of what not to do, primarily because I made mistakes!

Outcast923:
multiple PWM.

What's PWM got to do with this or did I miss something?

You would/could use PWM to control the bot's speed depending on sensor data. You might find the need for sharper turns. Also, reducing speed will increase battery life. Without PWM the speed is either 0 or 255. PWM allows slower speeds and can be used to calibrate motors if not all of them rotate at the same rate. You don't need to use PWM, but it is something I would think about in the design phase.

Question-- is there a specific reason for using multiple sensors versus less sonic sensors attached to Servos. 180 degree servos pretty cheap and 360 degree. Ones not too price.

Again, it is hard to give more specific suggestion without knowing what you want your bot to do.

Could you say a little about that. I or others might then be better able to help.