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.

Let's get started

Install Node.JS v. 8.9.3

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.

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: