I followed along the first half of Chapter 2 of Kassandra Perchs’ book, Learning JavaScript Robotics, to learn more about the basic outline of a Johnny-Five program. The three basic concepts I focused on were objects, functions, and events.

[all information below is paraphrased from Learning JavaScript Robotics, which is linked under Resources]


Objects usually represent physical electronic components. Some examples of an object in Johnny-Five would be the five object, which represents the Johnny-Five Library, the board object, which represents the microcontroller, and the LED object, which represents the physical LED.


Functions represent the actions your objects (and therefore the robot) can do. Examples of a function would be .off().on(), etc.


Events are fired on objects and represent observable points in a program. An example is when a board object fires a ready event when it’s ready to receive instructions. In Johnny-Five, and with robots in general, event-based programming is the best type of programming, as opposed to loop-based or interrupt-based programming. This means that instead of saying “every [A] seconds, I want to check for [B] and start [C]”, programming using the format “When [X] happens, I want [Y] to happen”. This type of programming makes it easier to write robotic programs – especially for beginners!

Basic Format for Most Johnny-Five Scripts

  1. Create a board object
  2. Create a listener and handler for ready event
  3. (Within the ready event handler) create component objects and call functions through them

Analyzing the Blinking LED Script