Problem with serial print

Hello,

I am currently making a code for a spotify remote which goes to the next song when you turn a triangle right and goes to the previous song when you turn the triangle left, I use LDR's as sensors on each side of the triangle. This is my code:

const int sensorPinA = A0;
const int sensorPinB = A1;
const int sensorPinC = A2;
const int sensorPinD = A3;
int sensorValueA = 0;
int sensorValueB = 0;
int sensorValueC = 0;
int sensorValueD = 0;
long registration1 = 0;
long registration2 = 2000;
int next = 1;
int previous = 2;
int playpause = 3;
int v = 40;

void setup() {
    Serial.begin(9600);
}

void loop() {

//Volgende
//Draaiing van vlak A naar vlak B 
  if(sensorValueA < v && sensorValueB > v && sensorValueC > v){
   registration1 = millis();
   delay(500); 
  }
  
  sensorValueA = analogRead(sensorPinA);
  sensorValueB = analogRead(sensorPinB);
  sensorValueC = analogRead(sensorPinC);

  if(sensorValueA > v && sensorValueB < v && sensorValueC > v){
   registration2 = millis(); 
  }
  
  if (registration2 - registration1 <= 1500 && registration2 - registration1 >= 0){
    Serial.print(next);
    registration2 = 2000;
  registration1 = 0;
  }
  
  
  
//Draaiing van vlak B naar vlak C
   if(sensorValueA > v && sensorValueB < v && sensorValueC > v){
   registration1 = millis();
   delay(500); 
  }
  
  sensorValueA = analogRead(sensorPinA);
  sensorValueB = analogRead(sensorPinB);
  sensorValueC = analogRead(sensorPinC);

  if(sensorValueA > v && sensorValueB > v && sensorValueC < v){
   registration2 = millis(); 
  }
  
  if (registration2 - registration1 <= 1500 && registration2 - registration1 >= 0){
    Serial.print(next);
     
  registration2 = 2000;
  registration1 = 0;
  }
 
  
//Draaiing van vlak C naar vlak A
   if(sensorValueA > v && sensorValueB > v && sensorValueC < v){
   registration1 = millis();
   delay(500); 
  }
  
  sensorValueA = analogRead(sensorPinA);
  sensorValueB = analogRead(sensorPinB);
  sensorValueC = analogRead(sensorPinC);

  if(sensorValueA < v && sensorValueB > v && sensorValueC > v){
   registration2 = millis(); 
  }
  
  if (registration2 - registration1 <= 1500 && registration2 - registration1 >= 0){
    Serial.print(next);
      registration2 = 2000;
      registration1 = 0;
  }
  

  
//Vorige
//Draaiing van vlak A naar vlak C
if(sensorValueA < v && sensorValueB > v && sensorValueC > v){
   registration1 = millis();
   delay(500); 
  }
  
  sensorValueA = analogRead(sensorPinA);
  sensorValueB = analogRead(sensorPinB);
  sensorValueC = analogRead(sensorPinC);

  if(sensorValueA > v && sensorValueB > v && sensorValueC < v){
   registration2 = millis(); 
  }
  
  if (registration2 - registration1 <= 1500 && registration2 - registration1 >= 0){
    Serial.print(previous);
  }
  
  registration2 = 2000;
  registration1 = 0;
//Draaiing van vlak C naar vlak B
if(sensorValueA > v && sensorValueB > v && sensorValueC < v){
   registration1 = millis();
   delay(500); 
  }
  
  sensorValueA = analogRead(sensorPinA);
  sensorValueB = analogRead(sensorPinB);
  sensorValueC = analogRead(sensorPinC);

  if(sensorValueA > v && sensorValueB < v && sensorValueC > v){
   registration2 = millis(); 
  }
  
  if (registration2 - registration1 <= 1500 && registration2 - registration1 >= 0){
    Serial.print(previous);
  }
  
  registration2 = 2000;
  registration1 = 0;
//Draaiing van vlak B naar vlak A
if(sensorValueA > v && sensorValueB < v && sensorValueC > v){
   registration1 = millis();
   delay(500); 
  }
  
  sensorValueA = analogRead(sensorPinA);
  sensorValueB = analogRead(sensorPinB);
  sensorValueC = analogRead(sensorPinC);

  if(sensorValueA < v && sensorValueB > v && sensorValueC > v){
   registration2 = millis(); 
  }
  
  if (registration2 - registration1 <= 1500 && registration2 - registration1 >= 0){
    Serial.print(previous);
  }
  
  registration2 = 2000;
  registration1 = 0;
  
  //Rechtop zetten voor play/pause
  if (sensorValueD >v){
   registration1 = millis(); 
   delay(500);
  }
  sensorValueD = analogRead(sensorPinD);
  
  if (sensorValueD < v){
   registration2 = millis(); 
  }
  
  if (registration2 - registration1 <= 1500 && registration2 - registration1 >= 0){
    Serial.print(playpause);
  }
  
 }

I have linked the serial print to a processing code which then sends a command to spotify (this works fine). The problem however is that the arduino keeps on sending the next or previous command every 500 milliseconds, even when the triangle is not moving, so the song keep skipping through. Can you guys help me because I can't figure out what the problem is...
Thanks in advance

void loop() {

//Volgende
//Draaiing van vlak A naar vlak B 
  if(sensorValueA < v && sensorValueB > v && sensorValueC > v){
   registration1 = millis();
   delay(500); 
  }

You don't think it's necessary to read anything, first?

The problem however is that the arduino keeps on sending the next or previous command every 500 milliseconds, even when the triangle is not moving, so the song keep skipping through. Can you guys help me because I can't figure out what the problem is...

Isn't it obvious? You send a value every 500 milliseconds, even if it is the same as last time. Don't do that.

I don't understand all of what that code is doing, but it certainly looks repetitive. Some functions that get called, instead of copy/pasting the code would be good.

Why is it necessary to keep assigning the same value to registration2?

Arrays would be good, too.

Finally, how does one "turn a triangle"? I don't understand what you are reading from the analog pins.