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