use pin 0 (RX) and 1 (TX) for wireless connection

Hi!

I tried to build a direct connection between two arduino boards. So there is a direct connection between TX of the one board and RX of the other board. And it works - sometimes. If I remove the direct connetion and again plug it in, I receive total different values. After disconnecting and connecting again there is the right value again (SOmetimes I get 19, sometimes 164, and then 52, which is correct then).

This is the code I used.



RECEIVER:
int income = 0;

int receiveLED = 12;

void setup() {
pinMode(receiveLED, OUTPUT);
Serial.begin(9600);
}

void loop(){
income = 0;

if (Serial.available() > 0) {
income = Serial.read();
Serial.println(income);
if (income == 79){
digitalWrite(receiveLED, HIGH); // sets the LED on

}else{

digitalWrite(receiveLED, LOW);

}
}else{
digitalWrite(receiveLED, LOW);

}

}



TRANSMITTER:

int send = 52;

int sendLED = 12;

void setup() {
pinMode(sendLED, OUTPUT);
Serial.begin(9600);
}

void loop(){
Serial.print(send, BYTE);
}


Thanks for your help!!