Using Serial.parseInt() with Arduino

Поділитися
Вставка
  • Опубліковано 10 гру 2024

КОМЕНТАРІ • 68

  • @electrucs219
    @electrucs219 Рік тому +6

    The way you explained the function is of a professional teacher. Thank you for this hard work.

  • @mateuswaikamp3699
    @mateuswaikamp3699 2 роки тому +3

    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.

    • @programmingelectronics
      @programmingelectronics  2 роки тому +1

      Thanks so much Mateus!

    • @SotPSotPSotP
      @SotPSotPSotP Рік тому

      The best is not in english its in american ☺

    • @saltytoast6669
      @saltytoast6669 Місяць тому

      @@SotPSotPSotP LOL. not even kidding. your comment is so hilarious that I started laughing out loud.

  • @Richie_
    @Richie_ 3 роки тому +2

    I'm signing up on Saturday.. Really looking forward to it all.

  • @kezhang64
    @kezhang64 2 роки тому +1

    It's a big help! thank you for your high-quality videos!

  • @bhoomikshetty7688
    @bhoomikshetty7688 3 роки тому +2

    This helped me a lot sir,
    Thankyou!

  • @jon_raymond
    @jon_raymond 3 роки тому +3

    This is really helpful and very well explained. Thank you.

  • @melodicachan
    @melodicachan 3 роки тому +2

    Que buenos videos! ❤️ Se nota que sabe lo que hace, Juntare dinero para hacerme con uno de sus cursos!

  • @freytube1
    @freytube1 Рік тому +1

    Well done videos. Prefect voice to follow also

  • @Europayacht
    @Europayacht 2 роки тому +1

    That was really something useful !!!
    .

  • @ahealthylife3116
    @ahealthylife3116 Рік тому

    Gerçekten süper anlatım olmuş türkçe alt yazı olması çok hoşuma gitti.sana çok teşekkür ederim

  • @DanTran-if2jt
    @DanTran-if2jt 2 роки тому

    Thank you, this is very specific!

  • @vikky452
    @vikky452 2 роки тому +1

    very good tutorial sir, thankyou

  • @DodgyBrothersEngineering
    @DodgyBrothersEngineering 3 роки тому +2

    Another great video. What does the : do in Serial.print(:dataIn); ?

    • @michaelcheich2481
      @michaelcheich2481 3 роки тому +2

      Thanks! That ":" was an error in the typing - sorry about that :(
      I didn't think anybody would spot it!

  • @RataJC91
    @RataJC91 2 роки тому +1

    this video is gold

  • @oqibidipo
    @oqibidipo 2 роки тому +1

    10:25 Incorrect. The timeout is between characters, not for the whole duration of parseInt().

  • @AzureSupremuZ
    @AzureSupremuZ 3 роки тому +2

    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.

    • @programmingelectronics
      @programmingelectronics  3 роки тому +2

      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!

    • @AzureSupremuZ
      @AzureSupremuZ 3 роки тому

      @@programmingelectronics thanks!

  • @krischlapek6939
    @krischlapek6939 Рік тому

    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

  • @robertherzog2087
    @robertherzog2087 Рік тому +1

    How can you see what functions are in a class?

  • @DodgyBrothersEngineering
    @DodgyBrothersEngineering 3 роки тому +2

    Any chance you can explain the difference between while (Serial.avalable() > 0) and if (Serial.available())

    • @programmingelectronics
      @programmingelectronics  3 роки тому +5

      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.

    • @DodgyBrothersEngineering
      @DodgyBrothersEngineering 3 роки тому +1

      @@programmingelectronics of course, I had both in my code but forgot why I used both methods. Thanks for the reminder.

  • @anujajacob9487
    @anujajacob9487 3 роки тому +2

    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?

  • @mradulbhardwaj3147
    @mradulbhardwaj3147 2 роки тому

    9:25 how to fix this 1000ms delay ?

  • @chrismolloy131
    @chrismolloy131 2 роки тому +1

    How do you receive a zero entry?

  • @rZERO_game
    @rZERO_game 9 місяців тому

    where we can find serial.cpp in arduino ide 2.3.2?

  • @terrygould3230
    @terrygould3230 3 роки тому +1

    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?

    • @programmingelectronics
      @programmingelectronics  3 роки тому

      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!

    • @nicolaslac1013
      @nicolaslac1013 2 роки тому

      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

    • @vikaspanse2105
      @vikaspanse2105 7 місяців тому

      ​@@programmingelectronics Thanks a lot. I was about to ask this.

  • @joshuapitong899
    @joshuapitong899 2 роки тому

    A lot of thanks.🙌

  • @maxpolaris99
    @maxpolaris99 Рік тому

    carriage return is ascii 13, if your data is 13 how does it know the difference in skip whitespace?

    • @astrabajtyt
      @astrabajtyt 5 місяців тому

      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? ;)

  • @godotology
    @godotology Рік тому +1

    thank you

  • @ToanLe-cm1zg
    @ToanLe-cm1zg 2 роки тому +1

    so helpful

  • @ipadize
    @ipadize 3 роки тому

    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)

  • @SPARKELECTRONICS
    @SPARKELECTRONICS 3 роки тому

    "SKIP_NONE' was not declared in this scope" i am getting this error

  • @digitalzoul57
    @digitalzoul57 3 роки тому

    What if we have many int values in the string ?

  • @mtalhakhalid1679
    @mtalhakhalid1679 3 роки тому

    There is another fubctuon itoa in arduino to convert to String like atoi convert string or char to int

  • @HOKMAN03
    @HOKMAN03 Рік тому

    Perfect

  • @warrenscorner
    @warrenscorner 3 роки тому

    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!

    • @agar.iodestiny8677
      @agar.iodestiny8677 2 роки тому

      what was it

    • @warrenscorner
      @warrenscorner 2 роки тому

      @@agar.iodestiny8677 Just what I thought. I cleared the buffer by doing a serial read and the problem went away.

    • @naasikhendricks1501
      @naasikhendricks1501 2 роки тому

      @@warrenscorner serial.flush(); and serial.availabletowrite should advise.

  • @user-oy7vn6mk1t
    @user-oy7vn6mk1t 2 роки тому

    Is there anyone who know library or function that can count an example like: " 2.8+(4-1)*(6/10) " ?

    • @0x8badbeef
      @0x8badbeef Рік тому

      OneNote. Put a "=" after that and press the "space bar" 2.8+(4-1)*(6/10)=4.6.

    • @0x8badbeef
      @0x8badbeef Рік тому

      Also OneNote, functions like log, sin, cos ... works as well.

  • @ahmadjaradat3011
    @ahmadjaradat3011 8 місяців тому

    The way you explained the function is of a professional teacher. Thank you for this hard work.