Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Learning JavaScript Robotics

You're reading from  Learning JavaScript Robotics

Product type Book
Published in Nov 2015
Publisher
ISBN-13 9781785883347
Pages 160 pages
Edition 1st Edition
Languages
Concepts
Author (1):
Kassandra Perch Kassandra Perch
Profile icon Kassandra Perch

Table of Contents (16) Chapters

Learning JavaScript Robotics
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Getting Started with JS Robotics Working with Johnny-Five Using Digital and PWM Output Pins Using Specialized Output Devices Using Input Devices and Sensors Moving Your Bot Advanced Movement with the Animation Library Advanced Components – SPI, I2C, and Other Devices Connecting NodeBots to the World, and Where to Go Next Index

Chapter 9. Connecting NodeBots to the World, and Where to Go Next

We have now covered just about everything you need to break into the wide world of JavaScript Robotics—except how to connect your bots to the web, and where to go from here. This chapter covers how to connect your NodeBots to online services, such as Twilio, and how Johnny-Five and other libraries will lead you to exploring your next set of projects!

In this chapter, we will cover the following topics:

  • Connecting NodeBots to the Web

  • Johnny-Five and the wide world of microcontrollers

  • Other JS Robotics libraries and platforms

  • Where to go from here

What you'll need for this chapter


You'll need your microcontroller, a temperature sensor, and a button—we're going to build a bot that sends a text message with the inside and outside temperature data when you press the button. If you can get your hands on a Particle Photon (check out the shop at www.particle.io), you'll also learn how to make your code work on both platforms without changing more than two lines!

Finally, you'll need your enthusiasm and curiosity—these are the things that'll give you ideas for your next NodeBots project!

Connecting NodeBots to the Web


Bots are really cool on their own—collecting data, outputting that data using colors, text, and even images! We can only do so much when our bots only talk to themselves. However, because of the Node platform that we build our NodeBots on, talking to web services and using Internet data in our projects is really simple. How so? Well, all you have to remember about NodeBots code is the following.

It's just a Node Server!

Implementing data retrieval and third-party APIs in our NodeBots is easy—especially when, thanks to npm, the modules that interface with all our favorite APIs are right at our fingertips.

Anything that you can install on your computer from npm, you can use with your NodeBots. For instance, I have a wearable that pulls colors from tweets—I use Twitter and the color modules from npm to make this happen smoothly!

For our first example, we're going to build a relatively simple bot, hardware-wise. It'll have a button and a temperature sensor. However...

Johnny-Five and the wide world of microcontrollers


We've been using Johnny-Five for the majority of this book, but we haven't really touched on one of its best features! While the REPL and the API are definitely strong points, what really stands out about it is its wide array of supported microcontrollers.

To be up to date with what Johnny-Five supports, check out johnny-five.io/platform-support—this page, as we saw in the earlier chapters, contains all the platforms that Johnny-Five supports, and also what types of component they support.

Wrappers, which we'll use in this build, are pieces of code that translate Johnny-Five's Firmata method of communicating to other platforms that don't necessarily use Firmata. In our build, for instance, we'll be using a Particle Photon, which uses a firmware called VoodooSpark. The particle-io wrapper essentially teaches Johnny-Five how to speak VoodooSpark, so we can use the Photon with our existing code.

Let's check out how easy it is to move code by moving...

Other JS libraries and platforms


Johnny-Five is definitely an amazing library and one of the cornerstones of NodeBots. However, one of the great things about open source hardware and software is that there is a litany of choices for you to explore in the world of NodeBots. I'll go into just a few of the many available, as new choices and projects are popping up every day!

Espruino

Espruino is an open source effort by Gordon Williams to create a microcontroller that runs JavaScript right on the board. There are currently two models available: the Espruino, which is the size of a credit card, and the Pico, which is nearly stamp-sized. Both interact via a USB connection.

Note that the Espruino doesn't use Node; it uses its own version of JavaScript that is in some places heavily modified. However, to most JavaScript developers, it will feel remarkably familiar.

The Espruino uses a Chrome app to code and flash the board, and has a good amount of documentation. As the entire effort is open-source...

Where to go from here


As we near the end of this book, I'll address the questions that I get most often: Where do I go from here? What do I build? Who do I ask for help?

As for what to build, you can do as I do. I keep a small notebook with me, although I also use my phone to record thoughts—I think about the small things I'd like to have in my day-to-day life. What problems can I solve? What would look cool? I write down these problems or wants and go over them later. Can I fix this with a NodeBot, I ask myself. If I can, awesome! I have my next project. I think you'll find you have more ideas than you thought you did with this method.

Once you've built something, write about it! The NodeBots community loves to see how you built something. Don't worry if it's not the next terrain-navigating hexapod; we'd like to see how you built your Internet-connected Christmas lights or your automatic dog-feeder. You can never have too many examples for people to look at, and one of the best ways to contribute...

lock icon The rest of the chapter is locked
You have been reading a chapter from
Learning JavaScript Robotics
Published in: Nov 2015 Publisher: ISBN-13: 9781785883347
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}