Arduino reads CSV file - Reads incoming Byte and compare with Previous Byte

Hi, I am a newbie at Arduino and Processing. My Processing sends CSV data (numbers) to Arduino. Arduino reads it and lights up green LED or red LED.

I want it so that the incoming Byte compares itself with Previous Byte. Or the incoming values compares itself to previous values.

so if it was 200, Green LED turns on. If it was 199, Red LED turns on. If it was 188, Red blinks on and if it was 199, Green LED turns on after.

200 - G (goes up = green)
199 - R (goes down = red)
188 - R
199 - G
…etc

If there is an alternative solution and way, please let me know.

Arduino Code

int green = 10;
int red = 9;
int incomingByte;

void setup() {
  Serial.begin(9600);
  pinMode(green, OUTPUT);
  pinMode(red, OUTPUT);
}

void loop() {
  
    Serial.available() == 'open'; 
    incomingByte == Serial.read();
   while (incomingByte < 'open') {
        digitalWrite(green, HIGH); 
        digitalWrite(red, LOW);
        delay(5000);
    incomingByte == Serial.read();
   if (incomingByte < 'open'){
        digitalWrite(green, LOW); 
        digitalWrite(red, HIGH);
        delay(5000);
   }
  
 }
}

Processing Code

import processing.serial.*;

Serial myPort;

Table table;
int brightness = 0;
int pmillis = 0;

void setup() {

  myPort = new Serial(this, Serial.list()[0], 9600);
  
  table = loadTable("NVDA.csv", "header");
   for(TableRow row : table.rows()) {
    int open = row.getInt("Open");

    println("open price is (" + open + ")");

    
    myPort.write("open");
    delay(5000);
   
  }    
}

void draw() {
}

test.ino (801 Bytes)

fade1.pde (872 Bytes)

 Serial.available() == 'open';

'open' is not a character (one byte). Single quotes for single characters ('X', '\n'), double quotes for strings ("string"). Serial.available does not return a character (or string). Serial available() returns the number of bytes waiting in the serial input buffer. Serial input basics will show how to receive and parse serial data. The post will help you format the data that is sent since you have control of how the data is sent.

Thanks groundfugus! I managed to work it out. :)