Datasheet
Chapter 2 • Shield, Lights, Servo Motors
52 • Robotics with the BOE Shield-Bot
positive terminal of a 5 V battery. When you connect the circuit to GND, it’s like connecting
to the negative terminal of the 5 V battery.
On the left side of the picture, one LED lead is connected to 5 V and the other to GND. So, 5 V
of electrical pressure causes electrons to flow through the circuit (electric current), and that
current causes the LED to emit light. The circuit on the right side has both ends of the LED
circuit connected to GND. This makes the voltage the same (0 V) at both ends of the circuit.
No electrical pressure = no current = no light.
You can connect the LED to a digital I/O pin and program the Arduino to alternate the pin’s
output voltage between 5 V and GND. This will turn the LED light on/off, and that’s what
we’ll do next.
Volts is abbreviated V. When you apply voltage to a circuit, it’s like applying electrical pressure.
By convention, 5 V means “5 V higher than ground.” Ground, often abbreviated GND, is
considered 0 V.
Ground is abbreviated GND. The term ground originated with electrical systems where this
connection is actually a metal rod that has been driven into the ground. In portable electronic
devices, ground is commonly used to refer to connections that go to the battery supply’s negative
terminal.
Current refers to the rate at which electrons pass through a circuit. You will often see
measurements of current expressed in amps, which is abbreviated A. The currents you will use
here are measured in thousandths of an amp, or milliamps. For example, 10.3 mA passes through
the circuit shown previously.
How a Sketch Makes the LED Turn On and Off
Let’s start with a sketch that makes the LED circuit connected to digital pin 13 turn on/off.
First, your sketch has to tell the Arduino to set the direction of pin 13 to output, using
the
pinMode function: pinMode(pin, mode). The pin parameter is the number of a
digital I/O pin, and
mode must be either INPUT or OUTPUT.