Book Image

Learning JavaScript Robotics

By : Kassandra Perch
Book Image

Learning JavaScript Robotics

By: Kassandra Perch

Overview of this book

Table of Contents (16 chapters)
Learning JavaScript Robotics
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Wiring up an external LED


For our first hardware project, we're going to wire an LED to the Arduino. An LED, or a Light Emitting Diode, is a component that lights up when electric current is passed through it. They come in many colors and sizes and are one of the most easy-to-use and versatile components in hobbyist robotics.

Setting up the hardware

First, take an LED. We'll determine the positive and negative leads of the LED—for this component, it's straightforward: the positive lead is longer than the negative lead.

Determining the positive and negative ends of an LED

To wire the LED to an Arduino, place the positive lead on pin 11 and the negative lead on the pin marked GND, just like in the following diagram:

Wiring up our LED

You can also use a breadboard if you wish to—it will look like the following:

Wiring an LED with a breadboard

Now that we've wired up the LED, we're going to make it blink as we did in the last chapter. The script looks very familiar:

var five = require("johnny-five")...