Sorry about my bad english, but I need to coment one thing. Here in Brazil a lot of peoples say "If you want good quality content, you will need to research in english." Today I started to search in english, and you with your content prove this fact to me, this content is perfect. I wish learn a lot with you (maybe with your courses), thank you so much.
Since parseInt() will ignore some non numbers like the " tacos" after extracting "314" from example you gave, I assume clearing whatever is left in the serial receive buffer would be important? If so how would you do that? Edit: Great video btw, I really appreciate the tutorials.
That is such a great question! To answer your question, you can use serial.read() with while loop to clear the rest of the buffer - you read out byte until serial.available() is equal to 0. Side note: It may be the case that the "other stuff" in the buffer is important, and you may want to read that in as well - which is why I am guessing this function does not just clear it for you. Hope this helps some!
Great info! Would be great if you could explain how to convert say 8 bytes received from serial to a single array os something that could be further used? Cheers
Great question! Here is my take... The "while" will keep you in it's block until the serial buffer is empty, where as the "if" (assuming something is in the serial buffer) will enter and then exit , regardless of how many bytes are left in the buffer.
If I type in "Write 20 34" on the serial monitor, I need to store 20 and 34 in two separate locations, if I use Serial.parseInt() then it will retrieve 20, discard "Write " in the serial receive buffer, now only " 34" remains in the serial buffer, is there a way to retreive this value 34 and get it stored?
If I wanted to send multiple values separated by commas e.g. 1243,9876,345,123 and have the Arduino save these in 4 variables e.g. data1, data2, data3, data4 how would this be done?
Great question! Many ways you could do this, but I think Serial.parseInt() would work paired with an array. You would want to run a loop perhaps to store these values in an array, and every time through the loop, you increment the array to save the next value. If you know there will only be some many comma separated values coming in, you could then copy those saved array values over to your variables. Hope this makes some sense!
Hi, Many thanks for these useful videos. But this answer doesn't make sense to me. I've called again the parseInt inside the Loop but it keeps only the last value entered, then if there is 2 values, 10 and 50 to add each other , the result is 10+10 or 50+50. But not 10+50. Any video any idea to solve this ? Thanks a lot
does it matter if the numbers are being transmitted as numbers or as text? (i want to send for example b200 from Nextion to arduino and 200 being a number)
Great video! This really helped me understand parseInt better. I’m hoping that you will answer my question. I’m sending data from Python as a string. The string would be 12,27,54 . My Arduino code is Int fn=Serial.parseInt(); Int sn=Serial.parseInt(); Int tn=Serial.parseInt(); lcd.print(fn); lcd.print(“,”); lcd.print(sn); lcd.print(“,”); lcd.print(th); So my display now shows 12,27,54 but after repeating this exactly 9 times my display will be 12,27,5412! Then it will start to display 27,54,12. I’m thinking that I’m leaving something in the buffer and it’s picking it up after 9 iterations. How do I fix this? Thank you!
The way you explained the function is of a professional teacher. Thank you for this hard work.
Glad it was helpful!!
Sorry about my bad english, but I need to coment one thing. Here in Brazil a lot of peoples say "If you want good quality content, you will need to research in english." Today I started to search in english, and you with your content prove this fact to me, this content is perfect. I wish learn a lot with you (maybe with your courses), thank you so much.
Thanks so much Mateus!
The best is not in english its in american ☺
@@SotPSotPSotP LOL. not even kidding. your comment is so hilarious that I started laughing out loud.
I'm signing up on Saturday.. Really looking forward to it all.
Thanks Richie!
This is really helpful and very well explained. Thank you.
Thanks for watching!
This helped me a lot sir,
Thankyou!
Glad it helped! Anything specific you were trying to do?
It's a big help! thank you for your high-quality videos!
Great to hear! Thanks for listening!
Que buenos videos! ❤️ Se nota que sabe lo que hace, Juntare dinero para hacerme con uno de sus cursos!
Well done videos. Prefect voice to follow also
Thanks!
this video is gold
Thanks Julio!!
Thank you, this is very specific!
very good tutorial sir, thankyou
Thanks for watching!!
That was really something useful !!!
.
Glad it was helpful!
How do you receive a zero entry?
How can you see what functions are in a class?
Another great video. What does the : do in Serial.print(:dataIn); ?
Thanks! That ":" was an error in the typing - sorry about that :(
I didn't think anybody would spot it!
Since parseInt() will ignore some non numbers like the " tacos" after extracting "314" from example you gave, I assume clearing whatever is left in the serial receive buffer would be important? If so how would you do that?
Edit: Great video btw, I really appreciate the tutorials.
That is such a great question!
To answer your question, you can use serial.read() with while loop to clear the rest of the buffer - you read out byte until serial.available() is equal to 0.
Side note: It may be the case that the "other stuff" in the buffer is important, and you may want to read that in as well - which is why I am guessing this function does not just clear it for you.
Hope this helps some!
@@programmingelectronics thanks!
Great info! Would be great if you could explain how to convert say 8 bytes received from serial to a single array os something that could be further used? Cheers
Any chance you can explain the difference between while (Serial.avalable() > 0) and if (Serial.available())
Great question! Here is my take...
The "while" will keep you in it's block until the serial buffer is empty, where as the "if" (assuming something is in the serial buffer) will enter and then exit , regardless of how many bytes are left in the buffer.
@@programmingelectronics of course, I had both in my code but forgot why I used both methods. Thanks for the reminder.
10:25 Incorrect. The timeout is between characters, not for the whole duration of parseInt().
Thanks for pointing this out!
If I type in "Write 20 34" on the serial monitor, I need to store 20 and 34 in two separate locations, if I use Serial.parseInt() then it will retrieve 20, discard "Write " in the serial receive buffer, now only " 34" remains in the serial buffer, is there a way to retreive this value 34 and get it stored?
You should be able to call parseInt() again to get out the remaining 34.
thank you
Thanks for watching!
Gerçekten süper anlatım olmuş türkçe alt yazı olması çok hoşuma gitti.sana çok teşekkür ederim
Thanks!
A lot of thanks.🙌
Thanks for all your comments Joshua!
If I wanted to send multiple values separated by commas e.g. 1243,9876,345,123 and have the Arduino save these in 4 variables e.g. data1, data2, data3, data4 how would this be done?
Great question! Many ways you could do this, but I think Serial.parseInt() would work paired with an array. You would want to run a loop perhaps to store these values in an array, and every time through the loop, you increment the array to save the next value. If you know there will only be some many comma separated values coming in, you could then copy those saved array values over to your variables. Hope this makes some sense!
Hi, Many thanks for these useful videos. But this answer doesn't make sense to me. I've called again the parseInt inside the Loop but it keeps only the last value entered, then if there is 2 values, 10 and 50 to add each other , the result is 10+10 or 50+50. But not 10+50. Any video any idea to solve this ? Thanks a lot
@@programmingelectronics Thanks a lot. I was about to ask this.
9:25 how to fix this 1000ms delay ?
where we can find serial.cpp in arduino ide 2.3.2?
so helpful
Glad it helped! Thanks for the note!
What if we have many int values in the string ?
does it matter if the numbers are being transmitted as numbers or as text? (i want to send for example b200 from Nextion to arduino and 200 being a number)
carriage return is ascii 13, if your data is 13 how does it know the difference in skip whitespace?
if you type 13 it will be 31 and 33 in ascii as those numbers are represented by other numbers ;) a bit confussing isn't it? ;)
Perfect
There is another fubctuon itoa in arduino to convert to String like atoi convert string or char to int
"SKIP_NONE' was not declared in this scope" i am getting this error
Great video! This really helped me understand parseInt better. I’m hoping that you will answer my question. I’m sending data from Python as a string. The string would be 12,27,54
. My Arduino code is
Int fn=Serial.parseInt();
Int sn=Serial.parseInt();
Int tn=Serial.parseInt();
lcd.print(fn); lcd.print(“,”);
lcd.print(sn); lcd.print(“,”);
lcd.print(th);
So my display now shows 12,27,54 but after repeating this exactly 9 times my display will be 12,27,5412! Then it will start to display 27,54,12.
I’m thinking that I’m leaving something in the buffer and it’s picking it up after 9 iterations.
How do I fix this?
Thank you!
what was it
@@agar.iodestiny8677 Just what I thought. I cleared the buffer by doing a serial read and the problem went away.
@@warrenscorner serial.flush(); and serial.availabletowrite should advise.
Is there anyone who know library or function that can count an example like: " 2.8+(4-1)*(6/10) " ?
OneNote. Put a "=" after that and press the "space bar" 2.8+(4-1)*(6/10)=4.6.
Also OneNote, functions like log, sin, cos ... works as well.
The way you explained the function is of a professional teacher. Thank you for this hard work.