Tutorial 06 for Arduino: Serial Communication and Processing

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ก.ย. 2024

ความคิดเห็น • 619

  • @andotech
    @andotech 8 ปีที่แล้ว +58

    Finally, a serial tutorial where the guy knows what he's talking about! I've watched a bunch and most are just noise pollution. Thank you!

  • @cetronics8211
    @cetronics8211 3 ปีที่แล้ว

    a serial tutorial where the guy knows what he's talking about! I've watched a bunch and most are just noise pollution. Thank you!

  • @vineetkaushik250
    @vineetkaushik250 11 ปีที่แล้ว +3

    Select "no line ending" in the drop down menu located beside the check boxes in the serial terminal window

  • @BadPennyDogBoy
    @BadPennyDogBoy 9 ปีที่แล้ว +5

    Excellent set of tutorials! It's guys like you that make the internet what it should be! Thanks for taking the time and trouble.

  • @MrSaemichlaus
    @MrSaemichlaus 10 ปีที่แล้ว

    I wrote a command parser. Took me a couple of headaches, but now it works and I have my LED dynamically blinking in all kinds of ways :D

  • @henrikchristensen8898
    @henrikchristensen8898 8 ปีที่แล้ว

    Using arduino Nano, and running Win10. There were some error messages in the "Processing" 3.2 version. After downloading the 3.1.2 it just worked. Very fine and simple tutorial - many thx

  • @mevansthechemist
    @mevansthechemist 8 ปีที่แล้ว +12

    These tutorials are awesome. Thank you, Jeremy!

  • @Elfnetdesigns
    @Elfnetdesigns 9 ปีที่แล้ว +4

    RS232 is +/- 3 volts to +/- 15 volts. Not flat 0 or 15. The MAX 232 and MAX 234 ICs were used in programming cables and RIBs to program older commercial 2-way radios and cellular phones. Today the MAX232 series ICs are used in A/V gear when you can interface with a 9 pin serial port like on a DVR for CCTV or the programming port in some satellite TV digital receivers. They are being phased out by the USB versions though.

  • @metalcore13
    @metalcore13 13 ปีที่แล้ว +1

    your tutorials are great because they explain exactly the things i need to solve my problems :)

  • @prcoy1
    @prcoy1 12 ปีที่แล้ว

    Standard functions in Processing are setup() and draw(). The draw() function is called right after setup() and automatically loops unless you tell it to stop.

  • @moons657
    @moons657 11 ปีที่แล้ว

    doesnt matter I didnt have the serial communication set up right, I now have it on "No line ending" and it is working perfectly :)

  • @gingewhiting1070
    @gingewhiting1070 10 ปีที่แล้ว +7

    The Processing listing shown in this demo, does not work on version 2.1.
    If you change the last line:
    brightness = float(port.readStringUntil('
    '));
    To:
    brightness = float(port.readString());
    it does work.
    FYI I am running win8.1 64bit.

    • @zerozeroisland
      @zerozeroisland 9 ปีที่แล้ว

      thanks so much! that fixed it for me :)

  • @Solar_Tech_Liam
    @Solar_Tech_Liam 12 ปีที่แล้ว

    The port will depend on what one your Arduino has chosen to use, it might be COM4 or some other one, but to get the console like he has on his screen, you can either use the button on the far left of the sketch window (it looks like a magnifying glass) or use the keyboard shortcut Shift-Command-M, when in the Arduino application.

  • @prcoy1
    @prcoy1 12 ปีที่แล้ว

    USB is 0V and 5V. He was referring to RS232 specs. Valid signals are plus or minus 3 to 15 volts.[Wikipedia]

  • @Kadasitimo
    @Kadasitimo 9 ปีที่แล้ว +2

    char val;
    void setup()
    {
    Serial.begin(9600);
    }
    void loop()
    {
    while(Serial.available() == 0);
    val = Serial.read();
    Serial.println(val);
    delay(50);
    }
    I think this will work even beter than your code because it works with lethers and number and etc. P.S love your tutorials!!!

  • @elmandibulas1605
    @elmandibulas1605 11 ปีที่แล้ว

    Marvellous explanation about using pods with processing and windows!! Thanks a lot, internet is God.... I was all day long fighting with processing about data sent by arduino by serial port, but didn't found a solution until I found your tutorial... :)

  • @marcelopalacio12
    @marcelopalacio12 7 ปีที่แล้ว

    You speak very fast for me, I do not know English. But this genius will put into practice your explanations thank you very much

  • @Solar_Tech_Liam
    @Solar_Tech_Liam 12 ปีที่แล้ว

    Also if your asking about the later example then replace his line of code with this:
    port = new Serial(this, Serial.list()[COM PORT HERE], 9600);
    in the brackets try 3 or 4 it usually is one of those two, though there are ways to check.

  • @prcoy1
    @prcoy1 12 ปีที่แล้ว

    10 and 13 are 'carriage return' and 'linefeed'. They are sent with println command.

  • @tcbetka
    @tcbetka 11 ปีที่แล้ว

    Take a look at the X-Plane SDK. It should give you the properties that you need to write/read to change the throttle. Then take raw data from the pot (via analogRead) and pass that into X-Plane via their API. I haven't done it in X-Plane, but I have in MSFS/Prepar3D. It's pretty straightforward. You need:
    1) Input from pot
    2) App to grab input and load it into X-Plane
    3) API call with variables to read/write in X-Plane.
    Try to use 10-bit ADC, as 8-bit is probably not enough resolution.

  • @duncpoly236
    @duncpoly236 9 ปีที่แล้ว +4

    I also had problems with flushing the serial buffer. After many attempts, printing "invalid" only once works with this:
    int ledPin=13;
    void setup()
    {
    pinMode(ledPin,OUTPUT);
    }
    void loop()
    {
    Serial.begin(9600);
    while (Serial.available()==0);
    int val=Serial.read()-'0';
    if (val==1)
    {
    Serial.println("Led is On");
    digitalWrite(ledPin,HIGH);
    Serial.end();
    }
    else if (val==0)
    {
    Serial.println("Led is Off");
    digitalWrite(ledPin,LOW);
    Serial.end();
    }
    else
    {
    Serial.println("Invalid!");
    Serial.end();
    }
    }

  • @Eurus721
    @Eurus721 6 ปีที่แล้ว

    Wow! Man I hope you’re making serious bucks. Very useful and hit the mark without sliding off topic. Very well done.

  • @rajk6140
    @rajk6140 8 ปีที่แล้ว

    Jeremy, you are the RORY McIlroy of the Arduino world. Awesome videos ! Thanks.

  • @sigi199191
    @sigi199191 13 ปีที่แล้ว +4

    20 mins are too short !!!
    I want more of this tutorials....your awesome !!!

  • @yashaswikulshreshtha1588
    @yashaswikulshreshtha1588 3 ปีที่แล้ว

    Whoaa!! Google used to look like this before in 2011!! Well its amazing

  • @nrsmac
    @nrsmac 12 ปีที่แล้ว

    @2BeN3 Serial.flush() in Arduino 1.0 has changed. the new syntax is (Serial.available()[GREATER-THAN]0)
    {
    Serial.read();
    }
    Glad I could help

  • @heiismail
    @heiismail 12 ปีที่แล้ว

    you are running it in beta version. try running it in older processing 1.5.1 for example.
    I had same problem first but i change it to older version and it work like a charm.

  • @Esteapen
    @Esteapen 10 ปีที่แล้ว +2

    I watched your tutorial from 1 up to this, I just wanna say thank you so much bro for making this tutorial, I learned a lot from you. Good day man!

  • @jaggie90
    @jaggie90 10 ปีที่แล้ว

    Your video series has helped me more than once. Thank you very much for your practical help!

  • @denissdubins4467
    @denissdubins4467 6 ปีที่แล้ว

    Finally, a serial tutorial that is actualy useful ;)

  • @gfx2006
    @gfx2006 12 ปีที่แล้ว

    You talk really fast! Not that there's anything wrong with it though as your voice is very clear and I have no problem understanding you as a foreigner.

  • @w0mblemania
    @w0mblemania 11 ปีที่แล้ว

    49 is the code for the character "1".
    10 is the code for newline.
    You are hitting the enter key.

  • @niekuma
    @niekuma 11 ปีที่แล้ว +2

    The following proposition for serial.flush() replacement:
    while(Serial.available()[GREATER-THAN]0) Serial.read();
    does not works exactly the same way as expected.
    Some signs slides out. I read that it could be great idea to put delay(50) before it.
    It's better but still doesn't work properly, especially with long strings. My proposition is a little more extended but it works perfectly:
    delay(10);
    while(Serial.available() [GREATER-THAN] 0){
    Serial.read();
    if (Serial.available() == 0)
    delay(10);
    }
    }

  • @Jose-ht3yl
    @Jose-ht3yl 9 ปีที่แล้ว +1

    Muy bien explicado y preparado el vídeo. Espero que continúes realizando mas.

  • @salauddeensyed5295
    @salauddeensyed5295 5 ปีที่แล้ว

    Finally a " no nonsense " tutorial...Thank you so much...

  • @madmax10101
    @madmax10101 11 ปีที่แล้ว

    Hi there sciguy14 :)
    Big THX for tutorial, btw - in your tutorial you can use:
    background(brightness);
    instead:
    background(0,0,brightness);

  • @tcbetka
    @tcbetka 12 ปีที่แล้ว

    I am just learning the Arduino library myself, but it doesn't appear that you can (this way). The read() method separates a serial stream into bytes and returns the first byte in the buffer. So as long as you are reading from the buffer in a loop, it will continue reading those bytes. You have to implement your own function to read data up to a CrNl, and combine and display all those bytes. The library is "Serial" so you have to do some extra processing. Using AVR Studio makes this a bit easier.

  • @michaeleilers3438
    @michaeleilers3438 8 ปีที่แล้ว

    If you go to the Arduino site, it tells you that prior to Arduino 1.0, Serial.flush() would remove any buffered incoming data. So, this means you will have to do the checking on your own from what I can tell.

  • @123456789robbie
    @123456789robbie 13 ปีที่แล้ว

    great, comprehensive instructions, clear instruction and great exlpaination of the parts of the programming. awesome work.

  • @osGFXman
    @osGFXman 8 ปีที่แล้ว

    Perfect! :) all tutorials should be just like this!

  • @onejordangerous
    @onejordangerous 12 ปีที่แล้ว

    It doesn't come up automatically, but Ctrl+Shift+M or (Tools-->Serial Monitor) gives you the window. Pretty easy!

  • @redav99
    @redav99 12 ปีที่แล้ว

    At the bottom of the serial monitor window there is a dropdown box.
    It probably says "newline". Change it to "No line ending".

  • @VigilianceAurelious
    @VigilianceAurelious 13 ปีที่แล้ว +4

    Ffff!!!
    Gotta love you dude!!
    I'm soooooo learning A LOT from you than reading some shiz on arduino website XD
    *watches next episode*

  • @Spacebirdy
    @Spacebirdy 11 ปีที่แล้ว

    I had the same issue too. The way to fix this is to get the 32-bit version of Processing. I hope this helps you.

  • @adheeshnakhate3963
    @adheeshnakhate3963 3 ปีที่แล้ว

    Doesnt feel like it was made in 2011 .Very good.

  • @jakesanchez3552
    @jakesanchez3552 5 ปีที่แล้ว

    This got me excited! This really opens up some doors.

  • @pkdsarp
    @pkdsarp 2 หลายเดือนก่อน

    In my case, a small delay was needed when trying to flush the buffer:
    delay(10); // give some time for the rest of the data to come in
    while (Serial.available() > 0) {
    Serial.read();
    }

  • @ZakKarimjee
    @ZakKarimjee 13 ปีที่แล้ว

    @sciguy14 I found it easier to send a letter, then the value, then use a case switch argument to read it to a different variable according to the letter sent.

  • @tousisat1
    @tousisat1 11 ปีที่แล้ว

    For all of those that ====>> while(Serial.available()>0){Serial.read();} ==> dont work
    try adding a delay before this line:
    delay(50);
    while(Serial.available()>0){Serial.read();}
    hope this help :)

  • @TheBull06
    @TheBull06 9 ปีที่แล้ว +5

    i really like how you teach thank you for these videos

  • @napoleon_bonaparte2462
    @napoleon_bonaparte2462 7 ปีที่แล้ว

    Just to chime in, when entering the serial port on linux for processing3, I used:
    port = new Serial(this, "/dev/ttyACM0", 9600);
    and it works. ttyACM0 could be different for other people but should be written on the arduino IDE

  • @omskariyazmaraikayer913
    @omskariyazmaraikayer913 4 ปีที่แล้ว

    excellent delivery . thanks Jeremy .

  • @tomd966
    @tomd966 13 ปีที่แล้ว +1

    Thank you very much for these tutorials, they've taught me a lot.
    If I'm plugging an RFID reader into the rx pin on the uno, when programming would I use serial differently to ensure it communicates with the rx pin and not with the computer??

  • @siimhs
    @siimhs 11 ปีที่แล้ว

    I had the same problem. Someone suggested to download 32-bit version of Processing and it it worked.

  • @akhila5597
    @akhila5597 4 ปีที่แล้ว +7

    why is my output coming like this
    1
    -38
    2
    -38

    • @davidtapia5492
      @davidtapia5492 4 ปีที่แล้ว +3

      use No line ending

    • @Excomunicater
      @Excomunicater 4 ปีที่แล้ว

      @@davidtapia5492 still does it but just on the same line 1-382-383-38...

    • @Excomunicater
      @Excomunicater 4 ปีที่แล้ว +3

      Oh I got it. Select No line ending in the serial monitor.

    • @gypyoutb
      @gypyoutb 4 ปีที่แล้ว

      my LED doesn't turn off if I typed 0, why?

  • @palewriter1856
    @palewriter1856 6 ปีที่แล้ว

    Jeremy
    Thanks for your excellent series! You're clearly gifted with superlative teaching skills, so I hope you manage to continue to bless the rest of us with that talent (which, I believe, extends well beyond the scope of whatever topic is at hand directly).
    Anyway, as this particular video is so long in the tooth, one can hardly expect you to be staying atop comments to it THIS far down the road -- BUT --
    Might I ask, as you have inserted the _minor_ aside herein of integrating Processing --
    would you perhaps shed a little light on WHY??? What does it bring to the table that one cannot do with Arduino's given environment? The fact that Arduino's was built on Processing in the first place makes me wonder - did they dumb it down significantly so that you "can't get there from here?" (always loved that paradoxical muse)
    No big deal, of course, but IF you happen on this AND it's quick and painless???
    Thanks again, and keep up the good work!

  • @dvgui
    @dvgui 11 ปีที่แล้ว

    Had the same problem... I just downloaded the 32-bit version and it worked fine

  • @latharajendramenon180
    @latharajendramenon180 4 ปีที่แล้ว

    Serial output and input may should have to be a string
    So it might be the ascii value

  • @TheAngryJazz
    @TheAngryJazz 12 ปีที่แล้ว

    This was a great tutorial !
    Serial Communication is really interesting, i hope you will do some follow up videos with more stuff to experiment with using serial communication!

  • @curiegupta7585
    @curiegupta7585 4 ปีที่แล้ว +1

    Thank you for the tutorial Jeremy.

  • @wongharry2993
    @wongharry2993 6 ปีที่แล้ว

    The tutorial still great at 2018 !! Thx Bro !!

  • @superdau
    @superdau 10 ปีที่แล้ว +4

    Please annotate the part where you talk about the voltage/pins of the connection, because it couldn't be more misleading. While USB may have 4 pins, it doesn't have RX/TX. RS232 on the other hand has RX/TX, but doesn't have 4 pins or power. You're mixing USB and RS232 together. This could lead people to think they can simply connect TX/RX to pins of USB and possible fry their USB port or the device on the other end.
    You either have a real serial port, which uses around +-15 volts. This means you'd need a logic level converter to talk to a microcontroller.
    Or you've got USB, which needs an USB-to-serial converter, which is a totally different thing. In this case there's no level shifting at all because you never have something else than 0 and 5 volts.

    • @christoforos82
      @christoforos82 10 ปีที่แล้ว

      Hello, I am new in Arduino world and electronics. I have Arduino Mega2560. I have a USB to serial converter on my laptop and connected directly Serial Pin 2 to Arduino Tx0, Serial Pin3 to Arduino Rx0 and Serial Pin 5 to Arduino GRD. I executed the simple program shown on the video but I get no communication. Is this approach correct? Do I need another converter in between or is there any other wire which is not connected? Any help will be appreciated.

    • @001marselle
      @001marselle 10 ปีที่แล้ว

      you have to use TTL to RS232 Converter

  • @SnappyFlossers
    @SnappyFlossers 11 ปีที่แล้ว

    press Crtl+Shift+M or go to tools -> Serial Monitor

  • @FutureInventions
    @FutureInventions 13 ปีที่แล้ว

    @hugosdominoes If I'm not mistaken, you need to your a char array.

  • @lazerusmfh
    @lazerusmfh 12 ปีที่แล้ว

    @sciguy14. Start this video, and turn on audio transcribing, then read the first few sentences of what it transcribes. HILARIOUS.

  • @mforlights
    @mforlights 11 ปีที่แล้ว

    Could you please do a tutorial on programming with any gyroscopes using serial communication with MOSI/MISO! thanks .. great videos.

  • @nayeemislam8118
    @nayeemislam8118 2 ปีที่แล้ว

    Thank you Jeremy! The contents are really cool!

  • @VirajTakale
    @VirajTakale 7 ปีที่แล้ว

    I watch these videos at 0.75 speed and I am not ashamed.

  • @StringssON
    @StringssON 11 ปีที่แล้ว

    helped so much! this is way better for learn than go to class :D!

  • @bmwkamal
    @bmwkamal 4 ปีที่แล้ว

    remark: serial.Flush() has changed over time and does not flush the data from buffer but rather stops transmission thereof.

  • @modmod1230
    @modmod1230 7 ปีที่แล้ว

    cordial saludo Jeremy Blum desde colombia y felicitaciones por esos videos interesantes.

  • @marktadlock5428
    @marktadlock5428 3 ปีที่แล้ว

    I wish you were writing and doing new videos explains more about setting up multiple inputs and puts and interfacing ai into the logic of the program

  • @garymize7272
    @garymize7272 7 ปีที่แล้ว

    Appreciate into to Processing. I expect I'll be using it to visualize Data Logging projects.

  • @34Merlin
    @34Merlin 12 ปีที่แล้ว

    Again you rock on these tutorials

  • @fabioribeiro5705
    @fabioribeiro5705 หลายเดือนก่อน

    You are very talented! Fantastic!

  • @truehate101
    @truehate101 12 ปีที่แล้ว

    problem with Serial.read() -'0' is it will only work for numbers 0-9, no double digit numbers

  • @Falken227
    @Falken227 11 ปีที่แล้ว

    The serial library in Processing is not compatible with 64 bit. Just download and use the 32 bit version.

  • @benjiasdf
    @benjiasdf 11 ปีที่แล้ว

    Go to serial monitor and change to "No line ending" in the bottom

  • @ShaniKumar-gn4oq
    @ShaniKumar-gn4oq 4 ปีที่แล้ว

    My question is.. I have 5 string variable
    Sting price;
    String set_count;
    String set_ml:
    String set_time;
    If( Serial. Available () )
    If i am sending through serial "price 220" So how to store this into price variable
    If sending "set_ml".. How to store in set_ml variable. And so on... I hope you're getting my point???

  • @Fr3dyish
    @Fr3dyish 12 ปีที่แล้ว

    Excelent tutorial, but i have a question ... i'm trying to read 2 analog pins at the same time and read it by Labview .. i already did it with one ... how can i do it with 2..? can u help me?

  • @shirleyachara3809
    @shirleyachara3809 3 ปีที่แล้ว

    Great demonstration, thanks.

  • @merkabahnkdac4986
    @merkabahnkdac4986 10 ปีที่แล้ว

    Got the flush working placing the delay before the while.

  • @alexanderthareparambil7067
    @alexanderthareparambil7067 9 ปีที่แล้ว

    Thanks for focusing the screen shots. Try and do the same for other videos too.

  • @Mytwistedvoices
    @Mytwistedvoices 9 ปีที่แล้ว

    I am following your example, the color of the screen will not change. How does Processing know what data to collect?

  • @hiteshrajpal3114
    @hiteshrajpal3114 9 ปีที่แล้ว +4

    how to open that java com3 window in computer

    • @tusharseth2539
      @tusharseth2539 7 ปีที่แล้ว +1

      In your Sketch, go to tools and Serial Monitor

  • @keithtucker1305
    @keithtucker1305 9 ปีที่แล้ว

    I changed the program as you need to ckeck the input buffer for valid items and dumped others

  • @inventorrr
    @inventorrr 12 ปีที่แล้ว

    The LED does not light up completely. You must give a hard output. pinMode(13, OUTPUT);

  • @matthewlhouck
    @matthewlhouck 12 ปีที่แล้ว

    If you have no logic to be performed while that value you can exclude the scope definition of the while (the {} bracket segment).
    This is along the same lines as to how the compiler will convert the following:
    if( variable == 1)
    doSomething();
    is logically treated as:
    if(variable == 1)
    {
    doSomething();
    }

  • @ColeslawProd
    @ColeslawProd 12 ปีที่แล้ว +2

    Remember the "();" at the end.

  • @rehmanzed
    @rehmanzed 3 ปีที่แล้ว

    After 10 years i am watching.

  • @mattbown
    @mattbown 3 ปีที่แล้ว

    You can also just use
    Serial.parseInt(), Serial.readString() :]

  • @MrHack4never
    @MrHack4never 12 ปีที่แล้ว

    @sciguy14
    not to sound like a perfectionist, but USB isn't RX/TX based, it is DATA+/- based
    DATA+ != DATA-

  • @PvtHaggard
    @PvtHaggard 11 ปีที่แล้ว

    they weren't referring to the arduino ide but rather the processing ide.
    oh and to fix the error download the 32 bit version of processing

  • @user-ln3cs5pl7i
    @user-ln3cs5pl7i 9 ปีที่แล้ว +1

    I had a problem with that program. If I entered more than one digit, I've received message for each character even with flush. Turns out, that there wasn't enough time time to receive all the characters in the buffer. I've fixed this by adding 10ms delay after the while loop.

    • @tsraikage
      @tsraikage 9 ปีที่แล้ว

      Сергей Мациевский i got the same problem... and sorry again how did you fixed this?

  • @ThePurpleFish12
    @ThePurpleFish12 13 ปีที่แล้ว

    I'm still not sure what the difference is between "=" and "==".
    I don't have my arduino yet, so i'm still a little confused.

  • @aleksagordic9593
    @aleksagordic9593 7 ปีที่แล้ว

    You can make short circuit between supply voltage and ground by configuring your circuit like this. Maybe it's better to make voltage divider and sense the signal from there. :)
    Great tutorial, very motivational i appreciate it very much! :) Subscribed!

    • @94D33M
      @94D33M 7 ปีที่แล้ว

      yeah...was thinking the same...

  • @agrxdrowflow958
    @agrxdrowflow958 9 ปีที่แล้ว

    OMG, how did I live before arduino! This is the coolest. Thank you Jeremy!

  • @prankmypants
    @prankmypants 12 ปีที่แล้ว

    hi great tutorial but how can i get say some dials to read out some values? really id like some graphs too and be able to arrange the space and make boxes with nice background and then pack into an exe. id even like to rename the driver too so it says whatever the project name is. thanks

  • @hablahei1
    @hablahei1 12 ปีที่แล้ว

    This is genious. You, my dear sir, is a genious.

  • @sankhalika
    @sankhalika 8 ปีที่แล้ว +15

    The serial.flush() isnt working for me. It is still sending multiple "invalid" messages. Anyone else facing such a problem? How to fix it?

    • @sparshmishra97
      @sparshmishra97 8 ปีที่แล้ว +3

      +Sankhalika Mukherjee Read the note in the description. It says that the Serial.flush() function has changed

    • @baraahalabi
      @baraahalabi 8 ปีที่แล้ว

      USE
      while(Serial.available()[GREATER-THAN]0)
      {
      Serial.read();
      }

    • @riktikt
      @riktikt 8 ปีที่แล้ว

      Where do we need to put that? I put it (while(Serial.available()>0) Serial.read();) at the bottom of the loop instead of the flush but it doesn't seem to change anything.

    • @RetroRobotRadio
      @RetroRobotRadio 8 ปีที่แล้ว +10

      Seems to help if you add "delay(100);" before the while command. Not sure why.

    • @riktikt
      @riktikt 8 ปีที่แล้ว +1

      RetroRobotRadio
      Thanks, that works.