Ok, so I'll try to keep this as tidy and simple as possible.
For my final school project, I'm doing a Sprinkler System with timers and schedules that is controlled over Bluetooth by AppInventor.
The app is pretty much done, but the Arduino code is what screws me the hardest. Here's the issue. I want to send an array with 28 positions, but when checking with the serial monitor while sending them, it gets to the position 25 and then literally gives up, it just doesn't send anymore.
I'm clueless, I even reworked the app and made it WAY more compact, it was actually a good thing. Also, my teacher told me it was the Serial Monitor's issue, that it ran out of memory, so I added in a Serial.Flush for good measure and kept getting the same results, even with a different Arduino. I'm using the Freaduino Uno btw.
What can I do to get all 28 values to be displayed in the serial monitor properly? Everything is commented, but please do ask if there's anything you don't understand. Also, here's a link for the AppInventor code:
String var; // Joins what it receives from "teste" and makes it into a signel word(ex: "teste" sends A B and C, so, var will be ABC.
char teste; // Reads what AppInventor sends, character by character
String vetor[27]; // The list that serves as database, which apparently, since I have 28 values "coming over" and in Arduino it starts at 0 and not one, I need only 27
int numero = 0; // Is used to count in which position of "vetor" we are
int on = 0;
void setup()
{
Serial.begin(38400); //Frequency at which the Bluetooth Module communicates
}
void loop()
{
while (Serial.available()) //While it receives information from the Bluetooth module, do:
{
delay(10); //10 milisecond delay to prevent errors from ocurring
teste = Serial.read(); //Each individual value that gets received is stored here
// The string I'm trying to send has this format: (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28)
if (isSpace(teste)) //If the value received is a space, it saves the current var in the current index and moves to the next
{
vetor[numero] = var;
Serial.println(numero);
Serial.println(vetor[numero]);
numero += 1;
var = "";
}
if ((teste != '(') && !(isSpace(teste)) && (teste != ')')) //If the test ISN'T a parentheses nor a space, it means it's still the same number, and will therefore add "teste" to "var"
{
var += teste;
}
if ((teste = ')')) //Here's said Flush, please do keep in mind I'm at home and I do not have the Arduino with me to test this, so please, be patient if things are out of order
{
Serial.flush();
}
if (numero == 27) //This is a test my teacher made, basically it's trying to print everything once it reaches the end, which is when "numero" is 27
{
Serial.println(numero);
Serial.println(vetor[numero]);
Serial.println("End");
numero = 0;
}
}
}