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

Setting up your development environment


Now that we've covered the basic ideas, we're going to set up the development environment for our first project. All the software used here worked on Windows, Mac, and Linux desktop computers at the time of writing this book.

Installing Node.JS

If you don't have Node.JS already installed, you can download an installer for your platform from nodejs.org. This installer will also install NPM or Node Package Manager, which will be used to manage the rest of the software that we'll be using.

Run the installer on your machine, which may require a restart. After this, open up your terminal application and run the following command:

node –-version

The output from this command should be 4.x.x, where x are integers.

Setting up your project and installing Johnny-Five

In your terminal, create a folder for your project and change directories to this folder:

mkdir my-robotics-project
cd my-robotics-project

Next, we're going to install Johnny-Five:

npm install johnny-five

You should see a spinner, followed by some output. Unless you see an ERR NOT OK message at the end of your output, you're good to go with Johnny-Five.

Note

On a Mac machine, you may need to install XCode developer command-line tools.

Connecting your Microcontroller and installing Firmata

First, you should get the Arduino IDE. Yes, we are still using JavaScript; however, we must make sure that there's a particular sketch (that's Arduino-speak for program) running on our board in order for Johnny-Five to communicate properly.

You can get the installer at the Arduino website (http://www.arduino.cc/en/Main/Software). This book assumes that you have version 1.6.4, but the versions in the 1.4 range should work as well.

Once you've downloaded the software, open it. Then, we'll make sure that your serial connection works.

Note

If you are using a board other than an Arduino, this step is not necessary. However, there may be other steps. These will be outlined with the wrapper plugin for your board.

Plug the USB cable into both the board and the computer. A few LEDs should light up on this board—this is normal. Then, go to the Tools menu in the Arduino IDE and hover over the ports submenu. You should see a list of ports that looks somewhat like the following screenshot:

You should see at least one entry in this list that fits the following format: /dev/cu.usbmodem*****. It may or may not have Arduino Uno next to it. If you see this, go ahead and click on it, because this is the port you will want to use for the Firmata installation. If you have this, it means your board can communicate with your computer, and you're ready to install Firmata.

To install Firmata on your board, go to File | Examples | Firmata | StandardFirmata, as shown in the following screenshot:

Once you've opened the sketch, you should get an IDE window that looks like the following screenshot:

Once this sketch is up, click on the Upload button (it looks like an arrow pointing to the right) to upload Firmata to your board. Once the uploading is done, you can close the Arduino IDE, and you will be ready to start working with JavaScript.

Tip

A developer named Suz Hinton (@noopkat) is working on a node program called AVRGirl that will remove this step in the near future. Take a look at www.github.com/noopkat/avrgirl to learn more!

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}