Created
August 26, 2018 18:37
-
-
Save bartoszbielawski/e6e01bc36630bdd91d4293c1ed7d444d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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