Hi, if you see the image, trying to paste to serial a series of numbers separated by commas and ends with "!". The code is suppose to make a new line after every "!", then separates each number in the set by a comma. Any suggestion?
#define INPUT_SIZE 72
char input[INPUT_SIZE + 1];
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println("Hello Arduino\n");
//Serial.print("20,30,203,20!202,2323,2323,23,23,23,!kllvflnvlsl!jfsefekkfs!kdflkslfk!");
}
void loop()
{
// put your main code here, to run repeatedly:
//Serial.print("20,30,203,20!202,2323,2323,23,23,23,!kllvflnvlsl!jfsefekkfs!kdflkslfk!");
if (Serial.available())
{
byte size = Serial.readBytesUntil('!', input, INPUT_SIZE);
input[size] = 0;
char* separator = strchr(input, ',');
if (separator != 0)
{
*separator = 0;
int data = atoi(separator);
++separator;
Serial.println(data);
}
separator = strtok(0, "!");
}
}