This is from a sketch I was using to try and make this work. The intent is that the outer loop runs by sending messages to the function, and the inner loop prints the current messages in the array
char messageArray;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
for (int i = 1; i < 51; i++){
String sendMessage = "Alarm Message - ";
sendMessage = sendMessage + i;
alarmHandler(sendMessage, i);
for (int j = 0; j < 51; j++){
Serial.println(messageArray[j]);
}
//Serial.println(sendMessage);
delay(1000);
}
}
void alarmHandler(String messageIn, int time){
for (int i = 4; i > 0; i--){
messageArray[i] = messageArray[i-1];
}
messageArray[0] = messageIn;
}