I'm Having a little bit of trouble with this bit of code here for my arduino.
Basically what I'm trying to do is send in a series of characters, turn it into an char array, and use that to run the rest of the program. I'm close because I know everything is working perfectly internally, but when I boot from the serial port the message isn't getting in.
I assume that at this point it probably is how I am constructing the array... or some oddity. Probably just a simple error in how I put the code together but I'm completely struck. (I was previously using a string, but because of how the arduino works with them, it pretty much makes using them for memory purposes impossible).
I'm using a java program (ardulink) to send the information into the program with a customized version I've edited. So simply put, the input has to be a series of characters, and I need it stored in an array.
void serialEvent ()
{
int arrayPostion = 0;
int i;
int maxArraySize = 20;
char CharArrayInLocal[20];
while (Serial.available() && !stringComplete)
{
char inChar = (char)Serial.read();
CharArrayInLocal[arrayPostion] = inChar;
arrayPostion++;
if (inChar == '\n')
{
stringComplete = true;
}
}
for (int i = 0; i<=19; i++)
{
CharArrayIn[i] = CharArrayInLocal[i];
}
}
char CharArrayIn[20];
is local to theserialEvent()
function and will not be available outside that very function? – JimmyB