Commit d2e86893 authored by Evan Raskob's avatar Evan Raskob

added string parsing example

parent d66b9341
/*
* An example showing how to get some values from a string
* with numbers encoded into it.
*/
void setup() {
// we declare variables for each parameter we want to read:
int x;
int y;
int z;
// this is the string we're reading from. It's a few values separated by commas
const char buf[] = "90,80,180";
// sscanf reads the values and stores them in variables we just declared. %d represents a number of digits to read
int n = sscanf(buf, "%d,%d,%d", &x, &y, &z);
// just print it out so we can show that it worked:
Serial.begin(38400);
while (!Serial);
Serial.print(x);
Serial.print(',');
Serial.print(y);
Serial.print(',');
Serial.println(z);
}
void loop() {
// no need to do anything
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment