Skip to content

Instantly share code, notes, and snippets.

@bartoszbielawski
Created August 26, 2018 18:37
Show Gist options
  • Save bartoszbielawski/e6e01bc36630bdd91d4293c1ed7d444d to your computer and use it in GitHub Desktop.
Save bartoszbielawski/e6e01bc36630bdd91d4293c1ed7d444d to your computer and use it in GitHub Desktop.
#include <Arduino.h>
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
}
void loop()
{
const char fmt[] = "i = %d, s = %s, f = %f";
//sposob 1
int i = 5;
char s[] = "Hello";
double f = 0.5;
Serial.printf(fmt, i, s, f);
//sposob 2
char buffer[128];
snprintf(buffer, sizeof(buffer), fmt, i, s, f);
Serial.println(buffer);
//sposob 3
String arduinoString;
arduinoString += String(i);
arduinoString += " ";
arduinoString += s;
arduinoString += " ";
arduinoString += String(f);
Serial.println(arduinoString);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment