This guide is intended to get you familiar with using Johnny-Five to control the outputs of your Photon. Although this section is optional, we recommend walking through it so that you can feel confident that your environment is set up properly.

Hook up your Photon

  1. Un-package your photon. Notice that your Photon has a name on its belly? You'll use this name when controlling your Photon.
  2. Hook your Photon to your breadboard, and then to power via USB.
  3. Make sure your computer is on the Nodebots network (password: whosjohnny)
  4. We've already provisioned and set-up your Photon on this network. Assuming everything is working properly, the light on your photon should be "breathing cyan".

WARNING: Some LEDs can be very bright, so you should avoid looking directly into them.

First step, let's make sure everything is working. You will be running JavaScript on your computer which will communicate to your Photon board via WiFi.

In this example, we'll just get an LED to blink.

  1. Make sure you've installed Node (prerequisites)
  2. Open up a command prompt and create a folder to work in
  3. From there, install Johnny-Five: npm install johnny-five. This will install into your "node_modules" folder.
  4. Now install the Particle-IO layer. By default, Johnny-Five works with Arduinos, so this library will tell Johnny-Five how to speak Particle: npm install particle-io.
  5. Create a file called "bot.js" and add the LED Blink Code.
  6. Your Photon has a built-in LED on pin D7, so you can hook one up if you want, but it is completely optional.
  7. Run your bot: node bot.js. You should see the LED blinking!
    • If your LED is not lighting, double check you wired it correctly as noted in the previous step and shown in the wiring diagram below.

LED Blink Code:

LED Blink Wiring:

LED Wiring Diagram

What's happening?

Your Photon is listening for commands on a TCP port on the local network. Your bot.js code is running on your machine. You don't know the IP address and port of your photon, but it has broadcast this information to the cloud. When you configured your code to use a token and your unique device name, it retrieves the IP address and port of your Photon and then connects to it.

Once that is complete, your code will receive a "ready" event. At that time, the LED abstraction will send on/off signals over the network to your chip. This is how you will be programming your photon today to do all sorts of things.