multiple maxbotix LVEZ on one UNO?

No daisy-chain, I am simply using your code, and separate sonars. If you check your original code
with my editing, you'll see tx,rx are just your same pins:

int SonarR = 5;
int TriggerR = 2;
int SonarL = 3;
int TriggerL = 4;

How are your sensors wired? I have only four wires coming from each sensor. For example the right sonic has +, -, RX to pin 2, and PWM to pin 5. Is that how your sensors are connected?

pinMode(rxpin, INPUT);

Why is rx pin an input? Shouldn't it be an output just to trigger the sensor into reading?

if(countL>prevCountL&countL>maxCountL){

s/b:

if( countL > prevCountL && countL > maxCountL ) {

or as I prefer:

if( (countL > prevCountL) && (countL > maxCountL) ) {

Were you going to change this in your code? It seems to work both ways, but it shouldn't since the single "&" is for binary.

Also I'm not getting the nine values in the array that get converted into mode even when I un-comment the "void printArray" part of the code. I am only getting the mode for each of the sensors.
if you could copy and paste the code as you are using it with your modifications it would be a big help. Thanks.

If you check my code in post #20 you'll see:

  read_sonar( TriggerR, SonarR, rangevalueR, arraysizeR);
..........

/**********************************************************/
void read_sonar(int txpin, int rxpin, int* ary, int asiz)
{

Also, must be "&&" in the other, I forgot to fix it in post #20 code. It doesn't matter in regards
the 2nd sonar, 1st sample problem.

Why do you have TX and RX in your code? Do you have TX wired up to something? And Why is RX an input instead of output? I'm missing something.

Local [temporary] variables are visible only inside the function, call them whatever you like.
I modified this to reflect the other changes I mentioned.

/**********************************************************/
void read_sonar(int trigpin, int pulsepin, int* ary, int asiz)
{
  pinMode(pulsepin, INPUT);

  for(int i = 0; i < arraysizeL; i++) {							    
    digitalWrite(trigpin, HIGH);
    delay(20);
    digitalWrite(trigpin, LOW);
    ary[i] = pulseIn(pulsepin, HIGH) / 147;
    delay(100);
  }
}

That makes more sense to me now. Thanks. But unfortunately the code only works good for a stationary robot ranging a stationary target (21" x 21" box. There's a 4-5 second lag to change the led's to reflect the change in range if I move the robot closer or farther away. I changed some of your delays to delayMicroseconds and still get ok results. Still some spikes, though. I think the main problem is with the inherent limitations of the sensor. It's fairly accurate but the accuracy isn't very repeatable (precise).

void read_sonar(int trigpin, int pulsepin, int* ary, int asiz)
{
pinMode(pulsepin, INPUT);

for(int i = 0; i < arraysizeL; i++) {
digitalWrite(trigpin, HIGH);
delayMicroseconds(20);
digitalWrite(trigpin, LOW);
ary = pulseIn(pulsepin, HIGH) / 147;

  • //delay(100);*
  • }*
    }[/quote]
    *I also tried it with the baud rate set to 57600 got the same results. The data sheet for the Maxsonar says 9600 baud, but it works ok anyway. *
    The parallax ping sensor seems to be more accurate and precise, but it's footprint is so narrow that it's worthless for my robot. I might have to rethink my whole approach to my project.

I think the 4-5 sec delay on Leds you mention is simply because your range check covers 14 - 36".

I wouldn't remove the delay, but you might shorten it to 50-msec - per the EZ datasheet.

Also, the Maxsonar 9600 bps is only if you use the RS232 mode output, which you're not using.

I think the 4-5 sec delay on Leds you mention is simply because your range check covers 14 - 36".

Can you elaborate on this?

The following code cuts the delay to about 2 seconds from the longer delay. I don't care about the LED's but at the moment they are simulating motors.

  for(int i = 0; i < arraysizeR; i++)
  {								    
    digitalWrite(TriggerR, HIGH);
    delayMicroseconds(200);
    digitalWrite(TriggerR, LOW);
    pulseR = pulseIn(SonarR, HIGH);
    rangevalueR[i] = pulseR/147;
    delay(50);

Do you agree with these delays?

Delays look good.

But unfortunately the code only works good for a stationary robot ranging a stationary target (21" x 21" box. There's a 4-5 second lag to change the led's to reflect the change in range if I move the robot closer or farther away.

I guess I didn't understand what this meant.

Hello!

Hello! I am working on a project on human presence detection. I have ordered 2 maxbotix ez3 an arduino uno and a buzzer. I want my sensors to detect presence one at a time so that I can detect when the person is inside a room. I can't find the tutorial where I connect the to sensors to the Arduino Uno. Please, can you help me?

It depends on what mode you want to connect them.
Read through the Product Documentation links from this link: http://www.maxbotix.com/products/MB1030.htm

And another: Arduino Playground - MaxSonar

If you just want to detect the presence of a person, passive infrared sensors are made just for that. Ultrasonic sensors are made for sensing distance. What exactly are you trying to accomplish? If you are more specific, we could be of more help.

I want to put the two sensors on each side of the door.If a person comes inside the room, sensor 1 will detect motion and then sensor 2. If the person comes out of the room the motion will be detected by sensors 2 1. Unfortunately, I found out late that it was much easier to use a PIR sensor. My coordonator told me to use ultrasonic sensors.So I have to use them for my project. And I can't change the sensors now because I have only 2 weeks until I have to present my project.

the maxbotix sensors will work, and if they are on opposite sides of the doorway they won't interfere with each each other. check the links from my last post. Get them wired up and write some code. Post a schematic and your code here, and I'll check back to help you.

here is the sketch I've done. I'm not sore if it's correct. I've used daisy chaining.I'll work tonight on the source code. Is the sketch ok?

Doc1.docx (26.4 KB)

very good sketch! I think you should try to use the pwm mode of the maxbotix sensor. It's not much different from what you are doing now. You don't have to daisy chain it either. They won't interfere. They are on different sides If the door right? I'll walk you through it. Just post some code using the links I gave you. If you don't understand I'll help you. I know it's frustrating, but I'm here to help. We'll make it happen.

I am making a miniature imitating a room with a door. I searched how to connect the sensor's pw to the digital output of Arduino but I didn't succeed. If I won't do a daisy chaining what type shall I pick? I am trying to figure the schematic out so I can start with the source code.

So I've connected the sensors to analog output. First sensor GND to GND +5v to +5v and Analog to A0.Second sensor Gnd to Gnd +5v to digital pin 5 and analog to A1. I've made a source code but only one sensor detects motion. I am having problem with making them detect motion only when a person is in the room (when sensor 1 detects and after that sensor 2 detcts motion). here is the source code
#define senzor_1 0 //// pinul analogic 0
#define senzor_2 1
int Val_1;
int Val_2;
int Buzz = 8; // pinul 8 la care este conectat

void setup()
{
pinMode(Buzz, OUTPUT);
Serial.begin(9600);
}

void loop()
{
Val_1=analogRead(senzor_1);
Val_2=analogRead(senzor_2);
delay(150);
Serial.print("Senzor 1 :");
Serial.println(Val_1);
Serial.print("Senzor 2 :");
Serial.println(Val_2);

if((Val_1 < 12) || (Val_2 < 12))
{
tone(7,262,250);
tone (7,524,250);
}
}

You need to divide Val_1 and Val_2 by 2 in order to get inches. If you want centimeters, you have to then multiply that result by 2.54.
http://www.arduino.cc/playground/Main/MaxSonar

Also your sensors are almost certainly interfering with each other. Can't you just use one sensor? If not you need to daisy chain them or learn how to trigger them. There are instructions on how to trigger them earlier in this thread.