filmov
tv
Using Serial.read() with Arduino | Part 1

Показать описание
🤩 FREE Arduino Crash Course 👇👇
Want to learn more? Check out our courses!
***Get the code, transcript, challenges, etc for this lesson on our website***
We designed this circuit board for beginners!
SHOP OUR FAVORITE STUFF! (affiliate links)
---------------------------------------------------
Get your Free Trial of Altium PCB design Software
We use Rev Captions for our subtitles
Arduino UNO R3:
Budget Arduino Kits:
Multimeter Options:
Helping Hands:
Soldering Stations:
AFFILIATES & REFERRALS
---------------------------------------------------
FOLLOW US ELSEWHERE
---------------------------------------------------
AN OVERVIEW WHAT WE’LL COVER:
The big picture of serial communication
The serial buffer
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
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:
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.
CONTINUED…
Want to learn more? Check out our courses!
***Get the code, transcript, challenges, etc for this lesson on our website***
We designed this circuit board for beginners!
SHOP OUR FAVORITE STUFF! (affiliate links)
---------------------------------------------------
Get your Free Trial of Altium PCB design Software
We use Rev Captions for our subtitles
Arduino UNO R3:
Budget Arduino Kits:
Multimeter Options:
Helping Hands:
Soldering Stations:
AFFILIATES & REFERRALS
---------------------------------------------------
FOLLOW US ELSEWHERE
---------------------------------------------------
AN OVERVIEW WHAT WE’LL COVER:
The big picture of serial communication
The serial buffer
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
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:
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.
CONTINUED…
Комментарии