Skip to content

Instantly share code, notes, and snippets.

@stonehippo
Created July 11, 2017 06:25
Show Gist options
  • Save stonehippo/3ec83bb6f5366e87227b562f699536a3 to your computer and use it in GitHub Desktop.
Save stonehippo/3ec83bb6f5366e87227b562f699536a3 to your computer and use it in GitHub Desktop.
Using sprintf in Arduino code
long counter = 0;
void setup() {
Serial.begin(115200);
}
void loop() {
char buffer[50];
sprintf(buffer, "The count is now %d.\n", counter++);
Serial.print(buffer);
delay(1000);
}
@stonehippo
Copy link
Author

This is a dumb little sketch that shows a use of sprintf() in an Arduino sketch. I don't recall why I wrote it, but maybe someone will find it useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment