Ivalue required as left operand of assignment

Hello,
I am making a robot that will basically play piano tiles. I have already checked forums and stuff but I still don't understand what's wrong.
P.S. I'm a noob so make the explanation as easy as possible to understand.
Thank you!

piano_tiles_master.zip (3.7 KB)

It's a common mistake for beginners to use '=' (assign a new value to the variable on the left) when they mean '==' (compare the left and right for equality, true or false).

#include <Servo.h>


unsigned long time;


long R1 = 0;
long R2 = 0;
long R3 = 0;
long R4 = 0;
unsigned long delay1 = 0;
unsigned long delay2 = 0;
unsigned long delay3 = 0;
unsigned long delay4 = 0;


Servo col1;
Servo col2;
Servo col3;
Servo col4;


void setup()
{
  col1.attach(3);
  col2.attach(5);
  col3.attach(6);
  col4.attach(9);
  pinMode(2, INPUT);
  pinMode(4, INPUT);
  pinMode(7, INPUT);
  pinMode(8, INPUT);
  pinMode(10, INPUT);
  pinMode(11, INPUT);
  pinMode(12, INPUT);
  pinMode(13, INPUT);
  col1.write(0);
  col2.write(0);
  col3.write(0);
  col4.write(0);
}


void loop()
{
  time = millis();
  if (digitalRead(2) = HIGH)
  {
    long R1 = time;
  }
  if (digitalRead(4) = HIGH)
  {
    delay1 = time - R1 - 15;
    delay(delay1);
    col1.write(5);
    delay(5);
    col1.write(0);
    long R1 = 0;
  }
  if (digitalRead(7) = HIGH)
  {
    long R2 = time;
  }
  if (digitalRead(8) = HIGH)
  {
    int delay2 = time - R1 - 15;
    delay(delay2);
    col2.write(5);
    delay(5);
    col2.write(0);
    long R1 = 0;
  }
  if (digitalRead(10) = HIGH)
  {
    long R3 = time;
  }
  if (digitalRead(11) = HIGH)
  {
    int delay3 = time - R1 - 15;
    delay(delay3);
    col3.write(5);
    delay(5);
    col3.write(0);
    long R1 = 0;
  }
  if (digitalRead(12) = HIGH)
  {
    long R4 = time;
  }
  if (digitalRead(13) = HIGH)
  {
    int delay4 = time - R1 - 15;
    delay(delay4);
    col4.write(5);
    delay(5);
    col4.write(0);
    long R1 = 0;
  }
}

WARNING:

  {
    long R1 = time;
  }

THIS DOES NOT CHANGE THE VALUE OF YOUR GLOBAL VARIABLE 'R1'.
Because you specify a type, it is creating a NEW, LOCAL variable with the name 'R1' and assigning it a value. That variable is thrown away when you reach the end of it's 'scope': the '}'. Local variables only exist inside the block in which they are declared.

Remove the 'long' keyword to set the value of the global variable 'R1' that you declared at the top of the sketch.