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[x]);
delay (10);
Serial.print('^');
delay (10);
Serial.print(mylights[x]);
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);
}
}
}