Тёмный
No video :(

Using Serial.read() with Arduino | Part 1 

Programming Electronics Academy
Подписаться 231 тыс.
Просмотров 133 тыс.
50% 1

🤩 FREE Arduino Crash Course 👇👇
bit.ly/get_Ard...
Want to learn more? Check out our courses!
bit.ly/3u7DRmd
**Get the code, transcript, challenges, etc for this lesson on our website**
bit.ly/331I3Is
We designed this circuit board for beginners!
Kit-On-A-Shield: amzn.to/3lfWClU
SHOP OUR FAVORITE STUFF! (affiliate links)
---------------------------------------------------
Get your Free Trial of Altium PCB design Software
www.altium.com...
We use Rev Captions for our subtitles
bit.ly/39trLeB
Arduino UNO R3:
Amazon: amzn.to/37eP4ra
Newegg: bit.ly/3fahas8
Budget Arduino Kits:
Amazon:amzn.to/3C0VqsH
Newegg:bit.ly/3j4tISX
Multimeter Options:
Amazon: amzn.to/3rRo3E0
Newegg: bit.ly/3rJoekA
Helping Hands:
Amazon: amzn.to/3C8IYXZ
Newegg: bit.ly/3fb03X1
Soldering Stations:
Amazon: amzn.to/2VawmP4
Newegg: bit.ly/3BZ6oio
AFFILIATES & REFERRALS
---------------------------------------------------
►Audible Plus Free trial: amzn.to/3j5IGrV
►Join Honey- Save Money bit.ly/3xmj7rH
►Join Honey- Save Money bit.ly/3xmj7rH
►Download Glasswire for Free:bit.ly/3iv1fql
FOLLOW US ELSEWHERE
---------------------------------------------------
Facebook: / programmingelectronics...
Twitter: / progelecacademy
Website: www.programmin...
Are you trying to use Serial.read() to get data from a serial port to your Arduino? Maybe you’re using the Arduino Serial Monitor window and sending in data, or maybe you’ve got a program running on your raspberryPi sending data via serial to your Arduino board.
How do you use serial.read() to receive the data, and piece it together correctly? In this lesson you will learn exactly how to use Serial.read() to receive data from the serial port and stitch it together as one value.
AN OVERVIEW WHAT WE’LL COVER:
The big picture of serial communication
The serial buffer
Serial.read and Serial.available
Developing a protocol and strategy for reading in data from the serial port
Implement the strategy in Arduino code
BONUS: How to convert the serial data from a string to an integer
THE BIG PICTURE OF SERIAL COMMUNICATION
Let’s take a step back from Serial.read(), and talk about Serial Communication.
Serial communication is the process of sending one bit of data at a time, sequentially, from one place to another. Like say, sending data from your raspberryPi to a connected Arduino, or vice versa.
USB is one of the most common methods used for serial communication, hence the name Universal Serial Bus. Using Arduino we can easily send and receive data over a USB cable with the built-in Arduino Serial Library.
Now if you don’t know what an Arduino library is, it’s basically a bunch of code that has been bundled together, because it is often used together.
Imagine you were a barber, maybe you have a specific drawer in your barber shop for all your hair cutting tools. Every time somebody walks in for a haircut, you know exactly where to look, in that hair cutting drawer, and all your tools are right there.
Maybe you have another drawer with all the stuff you need for dying peoples hair, when someone walks in and asks to get their hair dyed red, you know exactly which drawer to open. Same thing with Arduino libraries. Arduino libraries put together a bunch of software functions that help you with specific tasks.
SERIAL LIBRARY FUNCTIONS
For serial communication, we can use the built-in Arduino Serial library.
The Serial library has functions like:
Serial.begin()
Serial.read()
Serial.available()
Serial.parseInt()
Serial.parseString()
Serial.parseFloat()
Serial.print()
Serial.captCrunch()
OK, we know that Serial Communication over USB is how we can talk between one device and another, and we know that the Arduino Serial library is the set of tools we’ll use for serial communication. But where does the data that comes from another device actually go on the Arduino?
THE SERIAL BUFFER
The answer is the serial buffer, or perhaps more precisely, the serial receive buffer. When bits of data start streaming in from your computer, a piece of hardware on your Arduino called a UART will assemble each of the 8 bits into a byte, and store those bytes for you in the Serial Receive Buffer.
The serial receive buffer can hold 64 bytes.
The data you send from your computer, to your Arduino, will end up in the serial receive buffer.
How do you get this data? That is where Serial.read() comes in.
CONTINUED…
bit.ly/331I3Is

Опубликовано:

 

28 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 34   
@scienceoftheuniverse9155
@scienceoftheuniverse9155 3 года назад
You were the first person to teach me Arduino programming back then 2016. Thank you so much, you did a wonderful job. I really appreciate your work.
@programmingelectronics
@programmingelectronics 3 года назад
So awesome! Thanks for your note!
@metelomaniac
@metelomaniac 3 года назад
Man, you immediately made me a subscriber. I was struggling a lot on that thing
@h-h1859
@h-h1859 2 года назад
Mee too.I was exhausted watchin other videos and reading websites because they all had something missing.this video is perfect.insta subbed
@tonykaz6083
@tonykaz6083 2 года назад
haizz i thank you so much, serial.available and read function in this world no one explained it well enough for me to understand, finally i can understand it thanks to you.thanks
@programmingelectronics
@programmingelectronics 2 года назад
Thanks for the note Tony!
@devendrasuthar5530
@devendrasuthar5530 3 года назад
this is really amazing to watch this , I want to thank you for this to making it easy to understand cause I was really struggling that how the reading data works.
@programmingelectronics
@programmingelectronics 3 года назад
Thanks for watching!
@yashaswikulshreshtha1588
@yashaswikulshreshtha1588 3 года назад
@@programmingelectronics Hey I loved your video so much, I struggled a lot on this but you're a saver. Can you please make a video on Arrays? and can you let me know the road map to advanced programming, like a perspective of on which level you stand where you need go, I really want to learn programming using Arduino, however I can switch to different one but since I am comfortable with this I can learn this first and learn others after this
@creativebeeengineering2810
@creativebeeengineering2810 2 года назад
You guys are simply the best
@programmingelectronics
@programmingelectronics 2 года назад
Thanks so much!! Really appreciate that!
@praweenthakur741
@praweenthakur741 3 года назад
Thanks teacher I want more or whole course video Love your hard work
@FreeJ4ck
@FreeJ4ck 4 месяца назад
Wonderful way to show the serial functions ❤
@stormbytes
@stormbytes 2 года назад
Terrific explanation. Thank you for the video!
@programmingelectronics
@programmingelectronics 2 года назад
Glad it was helpful!
@midhunmohan0m0pillai
@midhunmohan0m0pillai 3 года назад
Ultimate video that explains aurdino UART in grate way . Fantastic thanks lot for the explanation.
@programmingelectronics
@programmingelectronics 3 года назад
I'm glad it helped midhun!
@mingosutu
@mingosutu 6 месяцев назад
Great tutorial. Man, I was going to ask: What is the difference in Serial.available() ==0, Serial.available() and Serial.available() >0 ??😄 Now I got it. Thanks
@programmingelectronics
@programmingelectronics 6 месяцев назад
Great! Glad it helped!
@cesarespiller2435
@cesarespiller2435 Год назад
Great video
@programmingelectronics
@programmingelectronics Год назад
Thank you!
@andrewwolf4430
@andrewwolf4430 10 месяцев назад
What about using old style serial ports?
@kei5985
@kei5985 3 года назад
yes!
@robbywildan1226
@robbywildan1226 3 года назад
Make it playlist
@joshuapitong899
@joshuapitong899 2 года назад
Super thanks.🙌
@programmingelectronics
@programmingelectronics 2 года назад
Thanks for watching!!
@krishnawa_
@krishnawa_ 3 года назад
Awesome
@jcs220
@jcs220 Год назад
Caso quiséssemos acionar um led a distancia, usando módulos de comunicação sem fio e dois arduinos(Um transmitindo o comando e outro recebendo, via serial, como seria o código fonte? Obrigado
@homeworxchannel4120
@homeworxchannel4120 3 года назад
I'm trying to build a HID with a single pull toggle. I assume I could use a high, low code that if the switch is high it would press a certain button and low it would press another button. Just not sure about how to write it.
@xrphobby1341
@xrphobby1341 10 месяцев назад
Thank you for your videos really helpful. Just a question how can you increase size/length the Serial Receive Buffer? Thank you😊
@cinnamonshake45
@cinnamonshake45 4 месяца назад
Lol im looking for a similar solution... the string im sending from my pc is too large and it cuts at the 64th character, if there are significant delays
@jenniferw8963
@jenniferw8963 Год назад
Thank you for this video. I really appreciate the work you put into it to make things as clear as possible. Really good stuff! I have a question. I have a Uni-T UT61E+ multimeter which has a usb cable for data logging output. I know the protocal and I know you can connect it to a PC and say use a Python program to read the data. I am wondering how I can instead use Arduino to read the data. Do I need a shield, something like USB Host to make this happen on Arduino? I imagine I can't directly connect the Uni-T directly to the Arduino? I just need to figure out how connect the two and I can make it happen.. I have the protocol detailed in a Python program.
@bendigorafaelh.6610
@bendigorafaelh.6610 2 года назад
How yo use it in Nano
@programmingelectronics
@programmingelectronics 2 года назад
If I am not mistaken, it would be the exact same way