Ready to get started? make sure to follow these steps

In order to get started with the lessons, you need to prepare your computer so that it can interact with the Arduino board.  You will need two main software components; the JavaScript run-time called Node.JS and the Arduino software along with the drivers.  Node.JS will allow you to run your JavaScript programs on your computer.  JavaScript will then send all the commands to the Arduino using the serial communications via the USB port.  The Arduino software will allow you to prepare the Arduino board with the code necessary to accept the commands send by Node.JS in real-time.

Why JavaScript and not C?

JavaScript is quickly becoming a versatile language used in many different environments.  Originally used in browsers to enhance the user experience, it has also been adopted for server side functions and lately in robotics with the availability of libraries such as serialcomm and Johnny-five.  JavaScript is much easier to learn for kids when getting started.  Kids will learn all basic constructs of a program, including variable assignments, flow control and function calling.

Questions?  If you have questions and if something is not clear, send us a note using this form

Let's get started

Node.JS

Have you installed Node.JS already?  If so, skip to the Arduino section.

nodejs.png
 

Watch the step by step video on how to install Nove.JS and the Johnny-Five library.

 

1. Download and install Node.JS

Download Node.JS from http://www.nodejs.org/en/download.  Node.JS is the JavaScript run-time process that will execute your code and translate it to commands received by the Arduino board.  Once the Arduino board receives the commands, it will send signals to the pins and components you have specified in your code.  This will allow you to control LEDs, motors and also receive information from sensors.

2. Verify Node.JS Installation

Make sure Node.JS was installed successfully and it is running by checking the version number.

2.1. Open a command prompt window.  The command prompt window will allow you to execute commands to start Node.JS and to execute your JavaScript programs

To find the command prompt simply search on the search bar next to the Windows icon.  On earlier releases of Windows, type "cmd" under "Run program..." after pressing the Start button.

2.2 Check the version of node installed by typing "node --version".  Make sure your version starts with 4.

If you get an error message, Node.JS was not installed or failed it's installation.  Try downloading it again and re-installing it.  You may see version 4.3.0 like me, or 4.4.0 or up.  You are set!

2.3 Install Johnny-five.  Johnny-five is the library necessary to send commands to the Arduino.  Install it using the command below:

npm install johnny-five


Arduino

Have you installed the Arduino software already?

You will not be using the Arduino IDE (Integrated Development Environment) to program the Arduino.  However, you will need to flash your Arduino board (upload software to it) that will translate the JavaScript commands and install any associated drivers for it to function properly.

ArduinoCommunityLogo.png

1. Download and Install the Arduino software

Select your platform and download either the Zip file or the installer.

At the end of the installation, your computer may ask to install the Arduino drivers.  Just say Yes and continue the installation until completion.

If you have a virus protection program, it may ask you to confirm the execution or launch of the program and installation of the drivers.  Just confirm and reply Yes.

2. Connect your Arduino board to the USB port.

The first time you plug in your Arduino, it will install a driver automatically.  Click on the message on the bottom of your screen and follow the steps.

Warning!

When adding electronic components on your Arduino board, you should disconnect the Arduino and reconnect it when ready to run your program.

3. Reboot your machine

Once your driver completed the installation, reboot your machine just to make sure everything is configured and running.


4. Prepare your Arduino board

Follow these steps to get Firmata uploaded correctly.

3.1 Launch the Arduino IDE by clicking on the Arduino icon. 

This will open the development environment.

 

3.2 Open the Firmata Sketch

Your Arduino board needs the Firmata software uploaded in order to communicate with JavaScript. 

 

3.3 Select the correct board

By default, Arduino should have already selected the Genuino/Uno board.  If not, select Genuino/Uno.

 

3.4 Select the correct port

Select the available port for your Arduino.  On most computer there should only be one port to choose from.

 

3.5 Upload the program

Click on the icon to upload the code.  Check the bottom of the IDE to make sure there were not errors during the upload.  Errors will show in an orange font.

 

Note:

On some PCs, Johnny-Five will not automatically detect you Arduino board.  When running your lessons, the program will time out and error out.  If this is the case, you will have to specify the port yourself in the JavaScript code (see example below).  To find out what port the Arduino is using, make sure your Arduino board is connected, open the Arduino IDE (click the Arduino icon), check the bottom right of the window.  The Arduino should be recognized and tell you what port it is on.  For example COM3.  In your JavaScript, when you create the Board, add the port like this:

var board = five.Board ( {port: "COM3"} );

 

Ready for your first lesson?