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.
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!
Did you just connect pin 7 to pin 7 or also GND to GND?
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
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?
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...
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?