Комментарии:
Very nicely explained, please continue with the additional functions.
ОтветитьThis video would have come in real handy just the other day, but better late than never... Would have been nice if you covered the use of the \ as in \"%s\".
ОтветитьBrilliant! Great info. I have been struggling with why it wouldn't print %.2f for a large majority of the day and now I know :D, thanks. You mention you have another vid explaining 'dtostrf' but I can't seem to find it. Can you point me in the right direction please? Thanks for your time and effort with your videos, they're super clear!
ОтветитьCheers Fella,
you are an amazing teacher. Love your channel. I am starting to understand things I thought were beyond my intelect!
Keep 'em coming!
Very excellent tutorial. You made this simple. Would be very interested in seeing an additional tutorial on using optional sub-specifiers.
ОтветитьAs always, great vid
ОтветитьLove it, thanks
ОтветитьThank You
ОтветитьIs it possible to use this to send multiple variable data to another arduino? If so how would you separate it on that side and plug the data into the correct variable on the recieving arduino?
ОтветитьGreat! ... I'd like to print the % sign, how i do this?
ОтветитьWould this work for LCD print?
ОтветитьYou have the best Arduino function tutorials. Thank you so much for this content.
ОтветитьI just use:
Serial.println("The " + String(numBurritos) + " burritos are " + String(tempStr) + " degrees F.");
I'm speechless!
One of the most annoying things on arduino is to print a long message like you have shown.
Mind blowing!
Top
ОтветитьMany thank.Excellent explain.
Ответитьthanks lot helpful
Ответитьplease make very detailed videos series on sprintf and sub-specifiers
ОтветитьNice explanation just what I hope will work with my microchip pic18f and C language. I'm doing a weather station
Ответитьgreat man. Really good explanation.. please do a follow up. Thx
ОтветитьYes , I want to buy ,lessions
Ответитьthank you sir, very good tutorial. plz make such wonderful tutorial.
ОтветитьWant know how to read from sd card and print on tft display using arduino uno
ОтветитьAwesome
Ответитьa good explanation...but thats still cumbersome. I prefer using the "Streaming.h" library. this allows for c++ style prints:
Serial << "hello world, I am " << intVar1 << " years old" << endl;
you can add as many as you like. my test indicated in requires no additional clock cyles to the native print.
"endl" is a new line, if you dont want it, just leave it off.
Excellent!!
ОтветитьReally great.✔️ Thanks.🙌
ОтветитьIsn’t it easier just to do it all in one line with Serial.println(String(variable1 + variable2 + ...)). No messing around with a buffer or worrying about if you got the right character specifier to suit your variable.
ОтветитьExcelente explicación! Muchas gracias!!!
Ответитьcongratulations for the class, very explanatory. I'm doing a project using a panel of leds-dot matrix to print texts read by the SD card. How can I include the temperature value read by a sensor (DB1820), in the text sent by reading the SD card? thank you if you can clarify this doubt for me
ОтветитьPlease do the additional tutorials
ОтветитьVery nice video!!!
ОтветитьThank you, sprintf looks very useful. Would there be any benefit of using sprintf over the following single line command to print a simple string of text with a variable (i)?
For example: Serial.println((String)"Relay"+(i+1)+" OFF"); Where the variable i is a numerical value starting at 0.
very useful n informative
ОтветитьIt is convenient and tidy but keep in mind this method is (a lot) slower than using a bunch of Serial.print commands, as I found out recently when I tried to clean up my new VU meter project code.
ОтветитьIt should be snprintf().
ОтветитьWhere has sprintf been all my life?
Better question is why don't I see it on the Arduino reference website and how many more hidden jewels are out there?
And this, people, is how a new generation is trained to enable buffer overflows and vulnerabilities...
Don't the authors know that sprintf is a deprecated and dangerous function ?
Nah, who cares.
The function is called snprintf
ОтветитьEverything said in this video is correct. However, a couple of things to bear in mind: sprintf is a LOT slower than Serial.print. Also, sprintf uses a lot of memory. On things like an Arduino Uno, Nano, or ATTINY85 you may struggle. What I do, to keep my code tidy, is write a function to display the things I want to display using Serial.print. You don't save on lines of code, but you can move those pesky Serial.print lines - which tend to clutter up the code - into their own functions. Which is much neater. It's also easier to remove them when you don't need them any more. So, using the burritos example from the video:
void displayBurritosInfo(int numberOfBurritos, float temperature)
{
Serial.print("The temperature of the ");
Serial.print(numberOfBurritos);
Serial.print(" is ");
Serial.println(temperature);
}
This seems inefficient. While the first example may have more lines of code, the second code certainly uses more resources. Using a character array requires the same data to be stored twice. Once in the program and variables and a second time in the character array. Then you are spending time sending that data into that memory location then sending that new memory location to print(). The first example is certainly faster and more efficient.
I understand that neat looking code is desired but the second example is harder to understand and less efficient. Seems like a bad idea.
This is potentially creating a buffer overrun. As it depends on how long the inserted numbers/strings are. When inserting strings you can never make the buffer big enough since you don't know the length of the dynamic strings at compile time.
Meaning you would need to allocate the buffer on the heap wasting already limited heap memory on an arduino.
Also this whole thing is just unnecessary. There is nothing wrong with multiple Serial print statements. In fact it's more efficient.
There are cases where sprintf makes sense to use. But this isn't one.
just use String() and + this point
Ответитьor you could use Serial.printf(" .... ", var1, var2, ... varn);
ОтветитьCan we use $"The taco is {tempTaco} degrees"
?
Sir, actually no need to use sprintf rather we can directly use the string concatenation property in serial.print() function
ОтветитьThe website will not send me the email needed for signup !!
ОтветитьThis is so much clearer than the online Arduino reference that is obviously written by well seasoned programmers and assume that you have solid grasp of the C language.
Ответить