user61967: I am not really 100% too sure how to do this but I am trying to make my arduino UNO communicate with my arduino MEGA. The reason why I needed to do this was because I was using the RFID module along with a TFT display and the problem I faced is that on the arduino mega they both needed pin 53. Luckily I have an arduino UNO so I just went for that instead for the display. I am trying to use the analogWrite() function to send analog signals from my MEGA over to the UNO so that the TFT display on the UNO can display the results. The UNO would also read the analog inputs coming from the MEGA. This did not work very well. The analog inputs are being sent from the MEGA but the UNO is not reciving them. I am using a PWN pin on the MEGA to send the analog output to the UNO.
This diagram shows what I mean:

These are the 2 compotents I am using:
https://i.stack.imgur.com/CqXdB.png
TFT display

RFID

This shows how the libary sets out the pins. I am only a beginner so I personally don't want to mess around with the libary.

user4143: Pin 53 is just the default "slave select" pin. There is nothing special about it. You can use any other pin as slave select, as long as the libraries for your devices allow it (check the documentation and tutorials for those libraries).
You cannot transmit information with analogWrite() since it isn't really analogue (it's PWM), and analogue doesn't have enough definition for reliably representing more than a handful of discrete values anyway.

user67324: You can use the I2C interface.
TX:
// Wire Master Writer
// by Nicholas Zambetti <http://www.zambetti.com>

// Demonstrates use of the Wire library
// Writes data to an I2C/TWI slave device
// Refer to the "Wire Slave Receiver" example for use with this

// Created 29 March 2006

// This example code is in the public domain.


#include <Wire.h>

void setup() {
  Wire.begin(); // join i2c bus (address optional for master)
}

byte x = 0;

void loop() {
  Wire.beginTransmission(8); // transmit to device #8
  Wire.write("x is ");        // sends five bytes
  Wire.write(x);              // sends one byte
  Wire.endTransmission();    // stop transmitting

  x++;
  delay(500);
}

RX:
// Wire Slave Receiver
// by Nicholas Zambetti <http://www.zambetti.com>

// Demonstrates use of the Wire library
// Receives data as an I2C/TWI slave device
// Refer to the "Wire Master Writer" example for use with this

// Created 29 March 2006

// This example code is in the public domain.


#include <Wire.h>

void setup() {
  Wire.begin(8);                // join i2c bus with address #8
  Wire.onReceive(receiveEvent); // register event
  Serial.begin(9600);           // start serial for output
}

void loop() {
  delay(100);
}

// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany) {
  while (1 < Wire.available()) { // loop through all but the last
    char c = Wire.read(); // receive byte as a character
    Serial.print(c);         // print the character
  }
  int x = Wire.read();    // receive byte as an integer
  Serial.println(x);         // print the integer
}

Schematic:

Image by Dronebot Workshop; check out their tutorial for more info: https://dronebotworkshop.com/i2c-arduino-arduino/


61967: <p>I am not really 100% too sure how to do this but I am trying to make my arduino UNO communicate with my arduino MEGA. The reason why I needed to do this was because I was using the RFID module along with a TFT display and the problem I faced is that on the arduino mega they both needed pin 53. Luckily I have an arduino UNO so I just went for that instead for the display. I am trying to use the <code>analogWrite()</code> function to send analog signals from my MEGA over to the UNO so that the TFT display on the UNO can display the results. The UNO would also read the analog inputs coming from the MEGA. This did not work very well. The analog inputs are being sent from the MEGA but the UNO is not reciving them. I am using a PWN pin on the MEGA to send the analog output to the UNO.</p>
<p>This diagram shows what I mean:</p>
<p><a href="https://i.stack.imgur.com/Wg6Dt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Wg6Dt.png" alt="enter image description here" /></a></p>
<p>These are the 2 compotents I am using:</p>
<p><a href="https://i.stack.imgur.com/CqXdB.png" rel="nofollow noreferrer">https://i.stack.imgur.com/CqXdB.png</a>
TFT display</p>
<p><a href="https://i.stack.imgur.com/vmdKP.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vmdKP.jpg" alt="" /></a></p>
<p>RFID</p>
<p><a href="https://i.stack.imgur.com/TfNjb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TfNjb.png" alt="enter image description here" /></a></p>
<p>This shows how the libary sets out the pins. I am only a beginner so I personally don't want to mess around with the libary.</p>
 4143: <p>Pin 53 is just the default &quot;slave select&quot; pin. There is nothing special about it. You can use any other pin as slave select, as long as the libraries for your devices allow it (check the documentation and tutorials for those libraries).</p>
<p>You cannot transmit information with <code>analogWrite()</code> since it isn't really analogue (it's PWM), and analogue doesn't have enough definition for reliably representing more than a handful of discrete values anyway.</p>
 67324: <p>You can use the I2C interface.</p>
<p>TX:</p>
<pre><code>// Wire Master Writer
// by Nicholas Zambetti &lt;http://www.zambetti.com&gt;

// Demonstrates use of the Wire library
// Writes data to an I2C/TWI slave device
// Refer to the &quot;Wire Slave Receiver&quot; example for use with this

// Created 29 March 2006

// This example code is in the public domain.


#include &lt;Wire.h&gt;

void setup() {
  Wire.begin(); // join i2c bus (address optional for master)
}

byte x = 0;

void loop() {
  Wire.beginTransmission(8); // transmit to device #8
  Wire.write(&quot;x is &quot;);        // sends five bytes
  Wire.write(x);              // sends one byte
  Wire.endTransmission();    // stop transmitting

  x++;
  delay(500);
}
</code></pre>
<p>RX:</p>
<pre><code>// Wire Slave Receiver
// by Nicholas Zambetti &lt;http://www.zambetti.com&gt;

// Demonstrates use of the Wire library
// Receives data as an I2C/TWI slave device
// Refer to the &quot;Wire Master Writer&quot; example for use with this

// Created 29 March 2006

// This example code is in the public domain.


#include &lt;Wire.h&gt;

void setup() {
  Wire.begin(8);                // join i2c bus with address #8
  Wire.onReceive(receiveEvent); // register event
  Serial.begin(9600);           // start serial for output
}

void loop() {
  delay(100);
}

// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany) {
  while (1 &lt; Wire.available()) { // loop through all but the last
    char c = Wire.read(); // receive byte as a character
    Serial.print(c);         // print the character
  }
  int x = Wire.read();    // receive byte as an integer
  Serial.println(x);         // print the integer
}
</code></pre>
<p>Schematic:</p>
<p><a href="https://i.stack.imgur.com/hg5l7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hg5l7.png" alt="Image by Dronebot Workshop; check out their tutorial for more info: https://dronebotworkshop.com/i2c-arduino-arduino/" /></a></p>
<p>Image by Dronebot Workshop; check out their tutorial for more info: <a href="https://dronebotworkshop.com/i2c-arduino-arduino/" rel="nofollow noreferrer">https://dronebotworkshop.com/i2c-arduino-arduino/</a></p>
<p><a href="https://i.stack.imgur.com/B0oUp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/B0oUp.png" alt="enter image description here" /></a></p>
