Dash and Dot are two lovable robots engineered to help teach kids basic coding concepts. They’re great for kids of all ages. Little kids can easily control the robots using the “Go” app like a remote control. As they grow older, the “Wonder” and “Blockly” apps introduce basic programming concepts.
We’re going to take a look at controlling Dash and Dot from our browser using JavaScript. We’ll learn a little about Bluetooth LE, asynchronous programming and bit-level operations along the way.
Bluetooth LE
The robots are controlled wirelessly via Bluetooth, specifically Bluetooth Low Energy or LE. Bluetooth LE handles less data than traditional Bluetooth, but consumes much less power. It’s perfect for sending short commands to a robot.
Bluetooth LE uses the Generic Attribute, or GATT protocol. In GATT-speak, a single piece of data (e.g. a sensor reading or command) is referred to as a Characteristic. Groups of Characteristics are referred to as a Service.
Each service and characteristic has a Universally Unique ID, or UUID. You’ll need to know the UUID values for the services and characteristics on the device you’re connecting to.
Web Bluetooth API
The Web Bluetooth API allows us to communicate with Bluetooth LE devices from the browser. At the time of writing, this API is only available in the Chrome browser. If you’re using another browser, you will have to switch over to Chrome. At least for this project.
But before we dive into the Web Bluetooth API, let’s discuss asynchronous programming in JavaScript.