Arduino serial.read to int
You are confusing integer values and ascii character values. When your

  int r1 = Serial.read();


reads a 0 it will read the ASCII character 0. The integer value of the character 0 is (decimal) 48 (check for instance this ascii table). So instead that line should read

  int r1 = Serial.read() - 48;


or even better

  int r1 = Serial.read() - '0';