Created
April 16, 2013 12:59
-
-
Save philippbosch/5395696 to your computer and use it in GitHub Desktop.
sprintf() in Arduino code
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
unsigned int i = 0; | |
void setup() { | |
Serial.begin(9600); | |
} | |
void loop() { | |
char buffer[50]; | |
sprintf(buffer, "the current value is %d", i++); | |
Serial.println(buffer); | |
} |
@RagBillySandstone you can't use Serial.println()
in this way.
@RagBillySandstone You are not bypassing the buffer that way. In your code, Serial.println() had to return a buffer. This is not the case. The buffer is created to store the character of the string and keep them, until they are passed to println as a parameter. So your code doesn't make sense at all, since you've changed the whole logic with your change :)
hola como puedo en arduino
ingresando numeros por teclado que cree una cadena numerica
enves de que se sumen?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is what I was looking for, and it inspired me to bypass the buffer -
sprintf(Serial.println(), "the current value is %d", i++);
Oddly enough, this compiled and ran but is printing blank lines. Any ideas why?