Book Image

Learning JavaScript Robotics

By : Kassandra Perch
Book Image

Learning JavaScript Robotics

By: Kassandra Perch

Overview of this book

Table of Contents (16 chapters)
Learning JavaScript Robotics
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Exploring SPI (Serial Peripheral Interface) devices


Serial Peripheral Interface (SPI) is a protocol to be used with certain devices in Johnny-Five and in general, robotics. It came about as a response to typical serial connections (which you don't see often in hobbyist robotics anymore), which were asynchronous in nature. This led to a lot of overhead, so SPI was developed as a way to ensure data was sent and received in a way that was efficient.

Tip

Keep in mind that when we talk about synchronous/asynchronous in this context, we are NOT talking about it as we would in JavaScript. You can still write async JavaScript functions around SPI methods!

How SPI works

In typical serial connections, you have a line from which data goes out (TX) and a line to which the data comes in (RX), and this makes communication difficult. How does the receiver know how fast the sender would be sending bytes, and when are they done sending? This lack of a synchronized time clock is what we mean when we say asynchronous...