Arduino to arduino serial communication

i need to have an arduino uno talk to an arduino mega by sending numerical values like 23 or something and i need to know how to do this. do i wire the tx and rx pins up together and have them share a ground or is there somthing more complicated? should the clock pin be used? thanks :)

Sounds right, did you try it?

budsiskos: Do I wire the TX and RX pins up together and have them share a ground or is there somthing more complicated?

The TX of one goes to the RX of the other because for each of the two wires, one side is transmitting and one side is receiving. Yes, you need a common ground. You can use SoftSerial if you need the D0 and D1 pins for a serial monitor.

Remember that you can't send data faster than the receiver can process the data or you will eventually run out of buffer space and characters will be dropped.

i have tried it and cannot seem to get them to talk. i have the rx of the uno connected to the tx1 of the mega and the ground is connected. Master code

void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.println(23, DEC);
  delay(2000);
  Serial.println(104, DEC);
  delay(5000);
}

Slave code

int x=0;

void setup() {
  Serial.begin(9600);
  pinMode(13, OUTPUT);
}
void loop() {
    x = Serial.read();
    
    if (x =23) {
      digitalWrite(13, HIGH);
    }
    if (x =104) {
      digitalWrite(13, LOW);
    }
}

You're probably sending the numbers as ASCII strings, and not as byte values.

Try to send using the BYTE modifier.

To verify communication change the slave loop to

void loop() {
  x = Serial.read();
  if (x!=-1) { digitalWrite(13,HIGH); delay(1000); digitalWrite(13,LOW); }
}

budsiskos:     if (x =23) {       digitalWrite(13, HIGH);     }

Note: x=23 is NOT the same as x==23! (It's a common mistake.)