Practical Arduino Robotics by Lukas Kaul
Author:Lukas Kaul
Language: eng
Format: epub
Publisher: Packt
Published: 2023-11-15T00:00:00+00:00
You can familiarize yourself more with the Serial Plotter by playing with the parameters at the beginning of this code. You can examine what effect enabling auto-scaling has (by omitting the min and max data lines) and what effects changing the print period has. You will find that too short of a print period can lead to unexpected, undesirable effects.
Explanation
Serial.print() writes the data to a transmit buffer and returns immediately. Behind the scenes, an interrupt-driven mechanism feeds the data from this buffer to the UART peripheral, byte by byte, without using the CPU. However, if you call Serial.print() too frequently or print too much at once, you may fill the transmit buffer faster than the UART can send the data. In this case, Serial.print() needs to wait for the UART to transmit the data and free up space in the buffer. Serial.print() then becomes a blocking call that can alter the behavior of your program. For this reason, adding printouts for debugging can sometimes make the bug disappear by unintentionally changing the timing of your program. This problematic phenomenon is jokingly called load-bearing printf. In practice, you want a high baud rate and leave a few tens of milliseconds between calls to Serial.print() to avoid this problem. You can also programmatically check the available space in the transmit buffer with the Serial.availableForWrite() function before a print command to be sure that you are not clogging up the buffer.
The Serial Plotter also has an input line, just like the Serial Monitor. With some modifications based on what we learned in the previous section, you can write a program that allows you to change the parameters of the sine and cosine waves on the fly right from the Serial Plotter. This is a great exercise to test and further your understanding of this chapter.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Linux Device Driver Development Cookbook by Rodolfo Giometti(3935)
Embedded Programming with Modern C++ Cookbook by Igor Viarheichyk(3622)
Implementing Cellular IoT Solutions for Digital Transformation by Dennis McCain(3556)
Embedded Linux Development Using Yocto Project - Third Edition by Otavio Salvador & Daiane Angolini(3389)
TinyML Cookbook by Gian Marco Iodice(3325)
Simplifying 3D Printing with OpenSCAD by Colin Dow(2843)
TinyML Cookbook by Gian Marco Iodice & Ronan Naughton(2604)
Fusion 360 for Makers by Lydia Sloan Cline(2220)
Networking A Beginner's Guide by Bruce Hallberg(2210)
Hands-On Linux for Architects by Denis Salamanca(2051)
But How Do It Know? by J. Clark Scott(2031)
Computers For Seniors For Dummies by Nancy C. Muir(1997)
Raspberry Pi and MQTT Essentials by Dhairya Parikh(1953)
Arduino Project Handbook, Volume 2: 25 Simple Electronics Projects for Beginners by Geddes Mark(1947)
9781803246888-ENHANCING DEEP LEARNING WITH BAYESIAN INFERENCE by Unknown(1902)
Hack and HHVM by Owen Yamauchi(1884)
31 Days Before Your CompTIA A+ Exams (Shanette Luellen's Library) by Benjamin Patrick Conry(1861)
MicroPython Projects by Jacob Beningo(1736)
Hands-On Internet of Things with MQTT by Tim Pulver(1708)
