You can try the below code using the serial monitor to see if it hangs after several cycles. Also, do you have an updated link to your relay board? Are you operating the relay directly from the arduino pin without a transistor? Is the relay a 5v or 12v control voltage relay?
// send 1 or 0 from serial monitor to control pin
int ledPin = 13;
void setup()
{
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
Serial.println("serial on/off test 0021"); // so I can keep track
}
void loop()
{
char c = 0;
if (Serial.available() > 0)
{
c = Serial.read();
if (c == '1') // assuming you send character '1', not a byte with value 1
{
digitalWrite(ledPin, HIGH);
}
if (c == '0')
{
digitalWrite(ledPin, LOW);
}
}
}