[Urgent]Connect 2 breadboard to the same Arduino.

Hey guys ! I'm actually looking for a way to be able to connect breadboards to the same arduino ! I've been trying non stop for the last hour and didn't find something that could work.

I need to connect 2 HC SR04 each one in a different breadboard to the same arduino. If someone would like to help me it would be amazing !

I'm actually doing this to a contest. So if I win with your help, the person will be rewarded !

Excuse me if I made some grammar/spelling mistakes, this isn't my native language.

Thank you.

If you have a reel of single strand AWG28 wire then cutting that up will save you waiting for delivery of
http://www.ebay.co.uk/itm/120Pcs-Male-Female-Dupont-wire-cables-jumpers-10-20-30cm-2-54MM-1P-For-Arduino-/182047669137?var=&hash=item2a62e2fb91:m:mtVZNmhxWtSxMkfGUGOaowg
or similar

I could sell you 20 pieces of 30cm lengths of single stranded wire, delivery by Royal Mail, posted first thing on Saturday from England for £40 all incl.

You've given no information on what the problem you're having is.

It should all just work - make sure you connect power and ground on the two breadboards back to 5v and Gnd, and then it's just like having two HC-SR04's on the same breadboard. The last poster covered what kind of jumper wire you should be using.

Remember also that breadboard connections can sometimes be unreliable (it's why I never use breadboard - I solder everything).

The electrical connections may not be your only problem. You'll probably have to work out some sort of round robin scheduling between the two units to ensure that any blocking activity for one unit (eg waiting for an echo using pulsln() etc. ) does not affect handling of the other unit. Some of the simple sketches I've seen would not scale up well to multiple units.

I've tried to connect multiple HC SR04 to the same breadboard and I haven't been able too ! :0 that explains why I couldn't make it with 2 breadboards :s

Could someone tell me how to do it ?

I thought that if you shared the same gnd and 5 volt it would work, but apparently it doesn't...

http://www.noelshack.com/2016-38-1474670288-capture.png

Your hookup seems ok, I think the problem may be in the programming. If you are using the Ping library then you must understand that the Ping unit from Parallax combines trigger and echo into one signal pin whereas the SR04 uses separate trigger and echo lines. You will have to modify the code to account for that.
Can you post the code you have so far?

Hi,
OPs fritzy......

Can you please post a copy of your sketch, using code tags?
They are made with the </> icon in the reply Menu.
See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

Tom... :slight_smile:

Here's the code guys !!

int triggerX=10;
int echoX=9;
int triggerY=4;
int echoY=5;



void setup() 
{


pinMode(triggerX,OUTPUT);
pinMode(echoX,INPUT);

pinMode(triggerY,OUTPUT);
pinMode(echoY,INPUT);
Serial.begin(9600);
  
}

void loop() 
{
int vitesse=340;

digitalWrite(triggerX,HIGH);
digitalWrite(triggerY,HIGH);
delayMicroseconds(10); 
digitalWrite(triggerX,LOW);
digitalWrite(triggerY,LOW);

unsigned long dureeX= pulseIn(echoX, HIGH);
unsigned long dureeY= pulseIn(echoY,HIGH);

dureeX=dureeX/2;
dureeY=dureeY/2;
float tempsX=dureeX/1000000.0;
float tempsY=dureeY/1000000.0;
float distanceX=tempsX*vitesse;
float distanceY=tempsY*vitesse;


Serial.print(distanceX);
Serial.println("X");
Serial.print(distanceY);
Serial.println("Y");
}

Alright, the code's in French, but it's still simple. Vitesse= Speed, duree= duration,Temps=Time.

I guess there's not much to add. Are you sure the picture is right ? If it is, then maybe I'm just doing it wrong (because I think the code is pretty much okay). I'll maybe send a picture if you don't found errors in the code.

Until then, goodnight !

I tried changing my code because Due_unto's post. And it worked ! Here how it is now !

int triggerX=10;
int echoX=9;
int triggerY=4;
int echoY=5;



void setup() 
{


pinMode(triggerX,OUTPUT);
pinMode(echoX,INPUT);

pinMode(triggerY,OUTPUT);
pinMode(echoY,INPUT);
Serial.begin(9600);
  
}

void loop() 
{
int vitesse=340;

digitalWrite(triggerX,HIGH);
delayMicroseconds(10); 
digitalWrite(triggerX,LOW);

unsigned long dureeX= pulseIn(echoX, HIGH);

dureeX=dureeX/2;
float tempsX=dureeX/1000000.0;
float distanceX=tempsX*vitesse;


Serial.print(distanceX);
Serial.println("centimètres X");

digitalWrite(triggerY,HIGH);
delayMicroseconds(10);
digitalWrite(triggerY,LOW);
unsigned long dureeY= pulseIn(echoY,HIGH);
dureeY=dureeY/2;
float tempsY=dureeY/1000000.0;
float distanceY=tempsY*vitesse;

Serial.print(distanceY);
Serial.println("centimetres Y");
}

Anyway, could anyone explain me what's the difference between those two codes ? It would be great !!

Compare the two sketches, how are the two sensors handled differently?

.

looffreezz:
. . .
Anyway, could anyone explain me what's the difference between those two codes ? It would be great !!

You can't interleave the operation of the 2 devices. The first statement here blocks the second:

unsigned long dureeX= pulseIn(echoX, HIGH);
unsigned long dureeY= pulseIn(echoY,HIGH);

You have to complete a full cycle with one device before starting on the second device.
That is you must do the following:

  1. Trigger device 1
  2. Wait for echo from device 1
  3. Calculate distance 1
  4. Trigger device 2
  5. Wait for echo from device 2
  6. Calculate distance 2

and NOT

  1. Trigger device 1
  2. Trigger device 2
  3. Wait for echo from device 1
  4. Wait for echo from device 2
  5. Calculate distance 1
  6. Calculate distance 2

Post #3 above anticipated this issue

Thank you so much guys !