Using Serial.parseInt() with Arduino

Поделиться
HTML-код
  • Опубликовано: 3 дек 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.

  • @jon_raymond
    @jon_raymond 3 года назад +3

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

  • @bhoomikshetty7688
    @bhoomikshetty7688 3 года назад +2

    This helped me a lot sir,
    Thankyou!

  • @kezhang64
    @kezhang64 2 года назад +1

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

  • @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

  • @RataJC91
    @RataJC91 2 года назад +1

    this video is gold

  • @DanTran-if2jt
    @DanTran-if2jt 2 года назад

    Thank you, this is very specific!

  • @vikky452
    @vikky452 2 года назад +1

    very good tutorial sir, thankyou

  • @Europayacht
    @Europayacht 2 года назад +1

    That was really something useful !!!
    .

  • @chrismolloy131
    @chrismolloy131 2 года назад +1

    How do you receive a zero entry?

  • @robertherzog2087
    @robertherzog2087 Год назад +1

    How can you see what functions are in a class?

  • @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!

  • @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

  • @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.

  • @oqibidipo
    @oqibidipo 2 года назад +1

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

  • @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?

    • @programmingelectronics
      @programmingelectronics  3 года назад

      You should be able to call parseInt() again to get out the remaining 34.

  • @godotology
    @godotology Год назад +1

    thank you

  • @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

  • @joshuapitong899
    @joshuapitong899 2 года назад

    A lot of thanks.🙌

  • @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.

  • @mradulbhardwaj3147
    @mradulbhardwaj3147 2 года назад

    9:25 how to fix this 1000ms delay ?

  • @rZERO_game
    @rZERO_game 9 месяцев назад

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

  • @ToanLe-cm1zg
    @ToanLe-cm1zg 2 года назад +1

    so helpful

  • @digitalzoul57
    @digitalzoul57 3 года назад

    What if we have many int values in the string ?

  • @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)

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

  • @HOKMAN03
    @HOKMAN03 Год назад

    Perfect

  • @mtalhakhalid1679
    @mtalhakhalid1679 3 года назад

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

  • @SPARKELECTRONICS
    @SPARKELECTRONICS 2 года назад

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

  • @warrenscorner
    @warrenscorner 2 года назад

    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 Год назад

      @@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.