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?
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.
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.
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.
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?
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.
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
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.