Serially confused

I am very new to programming the arduino, but I have been given a pretty complex task to undertake with it. My classmate is writing a program in visual basic for Windows. My program is to work in tandem with his. What needs to happen is, when he sends “receive int” (end character is ‘\0’) to the arduino, I have to get the arduino set to receive two different lists of four items. one of them is a list of names, the other is a byte value that will set outputs on port L of the Mega we are using. The order is name, then byte four times. The four names have to then be placed into an array and the bytes into a separate array so I can access their elements simultaneously. Song 1, byte 1. Song 2 with byte 2, etc. He is going to send ‘\0’ after each item to signal transition to the next.
I also have to design something for if he sends “send int” followed by ‘\0’ that will load the items in my arrays back to his program, still using ‘\0’ as the end of each individual item signal, and in the same order. list item then byte, four times.
These arrays also need to be saved to EEPROM so the arduino can perform other duties with this information away from the computer. This means that the information will also have to extracted from EEPROM when the program needs it. I downloaded the EEPROMex library, and I think I can do that part, but so far my efforts to communicate have yielded nothing. Below is a copy of the code I’ve thus far cobbled together. Any help would be tremendously appreciated.

void serialEvent() {
while (Serial.available()) {

inchar = Serial.read();
if (inchar == ‘`’) {

for (x = 0; x < 4; x++) {
Serial.print(lightlist);
delay (10);
Serial.print(’^’);
delay (10);
Serial.print(mylights);
delay (10);
Serial.print(’^’);
delay (10);
}
}

if (inchar == ‘|’) {
for (y = 0; y < 4; y++) {
Serial.readBytesUntil(’^’, mylist, 25);
delay (10);
lightlist[y] = mylist;
Serial.readBytesUntil(’^’, mylist, 25);
delay (10);
mylist[y] = int(mylist);
}
address1 = 96;
address2 = 0;
EEPROM.updateBlock(address1, lightlist, 4);
EEPROM.updateBlock(address2, mylights, 4);
}
}
}

Some of the syntax didn't paste quite right and the ^ symbol is where the \0 should be. I accidentally pasted the copy I was troubleshooting with.

Read this: How to post code properly

Pete

[codevoid loop() {
  
  while (Serial.available() > 0) {
    buffer[buffindex++] = Serial.read();
    if (buffindex == MAX_BUFF_SIZE) {
      buffindex=0;
      return;
      }
    if (buffindex > 6 && Serial.read() == '\0') {
      if (buffer == upload) {
        for (x = 0; x < 4; x++) {
          Serial.print(songlist[x]);
          Serial.print('\0');
          Serial.print(mypedal[x]);
          Serial.print('\0');
        }
      }
      
      if (buffer == download) {
        for (y = 0; y < 4; y++) {
          Serial.readBytesUntil('\0', mysong, 25);
          songlist[y] = mysong;
          Serial.readBytesUntil('\0', mysong, 25);
          mypedal[y] = int(mysong);
        }
        address1 = 0;
        address2 = 4000;
        EEPROM.updateBlock(address1, songlist, 4);
        EEPROM.updateBlock(address2, mypedal, 4);
      }
    }
  }]

Thank you. Here is my code from a version before I started troubleshooting and changing things. There are no errors when I check it, but it still does not work.

My program is to work in tandem with his. What needs to happen is, when he sends "receive int" (end character is '\0') to the arduino,

While the \0 is a terminating NULL, it is NOT sent as part of the serial data. It tells the sending program that it is done sending.

You need a different terminator for the Arduino to know when to quit reading. Typically, that it a carriage return or line feed.

I was wondering about that. Thank you. Can you see anything else I may have done wrong?

  while (Serial.available() > 0) {

This only guarantees you that that there is at least one character ready to be read, but inside the while loop you read two characters.

Pete