Connecting 2 Arduino Uno R3s

Hello, I'm trying to make two Arduino UNO R3 boards communicate between each other. i tried transferring data in this way.

The sender Board:

void setup(){
    pinMode(7,OUTPUT);
}

void loop(){
    if (something == something){// replaced with actual data
    digitalWrite(7,HIGH);
    delay(100);
    digitalWrite(7,LOW);
    delay(100);
    }
}

And my second R3's code

void setup(){
    pinMode(7,INPUT);
}

void loop(){
    if (digitalRead(7)==HIGH){ //this I've given just for example "mydatahere" and 123 are 
    //code here
    }
}

My connections are
1st UNO R3 ==> Computer Power Supply.
2nd UNO R3 ==> 9V Battery.
Both boards pin 7 is connected to each other.

^^^^^^

This method is not working. Please help.

Thanks.

Can you please, make your statements like below in order to receive some helps:
1. I have two UNOs which are named as: UNO-1 (the Sender) and UNO-2 (the Receiver). Both UNOs will be powered and operated by two USB Ports of my single PC.

2. I want to use UNO-1 to send the decimal number 1234 to UNO-2 using Software Serial UART (SUART) Port.

3. UNO-2 will receive the number and will show it on its Serial Monitor.

Please, guide me to proceed with the project.

Note: Once you can come up with a simple working system, then you can play around as much as you wish to experiment your all kinds of ideas!

  1. Did you just connect pin 7 to pin 7 or also GND to GND?
  2. I suggest to use "pinMode(7, INPUT_PULLUP);" to make sure that the receiving pin has a defined potential (does not float) in case the cable is not connected or broken.

Your second R3's code is just a shortened example? There is no reaction on reading HIGH ... (like switching a LED on/off).

P.S.: If you really want to transfer data (rather than only events) you could use software serial interfaces to connect both UNOs (TX <->RX, RX<->TX and GND<->GND) , see here for a library

https://www.arduino.cc/en/Reference/softwareSerial

Where is mydatahere declared? Where do you find the === operator?

Also, you need a common GND connection between the Arduinos.

One question is - how far apart are they?

The only reason to use two is because they are a significant distance apart, because if they were in the same place you would only require one. So - what sort of distance have you in mind?

Ok, Thanks! I'll try that!

mydatahere was just for an example... I had tried it with different variables and the whole code would have been really long to send here.

I tried Using "==" but since that also did not work, that's why used "===".
Wasn't sure if it was there in Arduino though.

Like the ground pin of one Arduino has to be connected to another's with jumper wire?

Yes, there has to be a return for the signal voltage to make a circuit.

That needs to be, in essence, 'debounced'. It's HIGH for 100msec, so it could be read many times.

Actually, the project us using a servo motor and SD Card reader... That's why some pins are clashing. so I separated out the code into 2 different Arduinos, because I don't have a Mega currently...

They are not really far apart... Like they are literally side by side...

So a delay of 1msec would do?

Oh ok... I will try that.

Using multiple Arduinos to get the number of pins required is a mistake that a lot of new users make. It is usually not necessary and more work and expense. If you provide a schematic* of your project we may be able to help you to make it with one Arduino and, perhaps, a few external chips like I2C or SPI port expanders and/or shift registers.

*hand drawn, photogrphed and posted is fine. Include all components, their part numbers and/or values and all power supplies.

No.
'A' makes its output HIGH for 100ms.
'B' basically sees it right away. 'B' does some stuff, at the end of that it digitalReads again and the signal from 'A' is still there HIGH.
What then?

B will basically play a voice file of 2seconds.

TMRPCM (The last thing u helped me with :slight_smile: )

So I guess, by the time the Arduino plays the file, the signal would have already stopped...

On that basis 'problem solved'.

I wouldn't be able to get any more parts, as I have to stick by a deadline... That was the reason of not migrating to a Mega too...

Yes, if connecting ground wires work :smile: