Well, as I suspected changing it to Serial.write('3') didn't change anything. Still get random 254's. Changing int to char on the slave makes no difference. Seems to be something with the modules
Code now looks like
Master
int button = 10; //push button
void setup()
{
Serial.begin(9600);
pinMode(button, INPUT);
digitalWrite(button, HIGH);
}
void loop()
{
int buttonOn = digitalRead(button);
if (buttonOn == 0) //when button is pushed
{
Serial.write('3'); //send 3 to the slave
}
Slave
void setup()
{
Serial.begin(9600);
}
void loop()
{
if(Serial.available() >0)
{
int input;
input = Serial.read(); //listen for master input
Serial.println(input); //print received data
}
}