# Simple LED chaser

Photo
(click for a larger view)
Description

This project demonstrates the basics of the patch shield with a six-LED chase. You can use it as a sanity check for your shield and your cables.

Here's the schematic for the LED circuit. A pin from the Arduino supplies power, which flows through the LED and a current-limiting resistor to ground.

An LED's forward voltage (the voltage at which it starts to conduct electricity and emit light) varies with color, but tends to be somewhere near 1.7v. With a 5v supply and roughly 1.7v across the LED, the voltage across the resistor is about 3.3v. With a 330 ohm resistor, that translates to about 10mA of current: enough to produce a decent amount of light without hogging too much current.

That's just a ballpark value though. If you don't have 330 ohm resistors on hand, anything from 100 ohms to 1 kilohm will work.

When you put the parts on a breadboard, it looks like this.

The LED and resistor are only part of the circuit though. We still need power and ground signals from the Arduino. Those signals will come through the patch shield and a cable to a breadboard header.

So first we have to decide which Arduino pins we want to use, then we have to decide how to connect the Arduino pins to pins on a breadboard header.

To do that, we use this.

It's a template that will make it easier to plan our connections. You can download a copy in any of several formats from the template page.

Let's say we want to use pins 1 and 2 of the breadboard header. Pin 1 will carry the ground connection, pin 2 will carry the power connection. We'll connect those to jack 1 of the patch shield.

Let's also say we want to use Arduino pin 5 to supply power to the LED. We can take the ground signal from any of the Arduino's ground pins.

We mark both of the ground signal's pins blue, then draw a line between them to indicate the connection. We do the same for the LED, using red.

Now we have a map that tells us how to patch the shield.

The actual patch looks like this.

I happen to have a couple hundred yards of old CAT5 cable left over from a commercial network upgrade, so I use chunks of that for my patch wires. The ring lines (solid color) are easy to use as-is. The markings on the tip lines (white plus color) rub off easily though, so I'm left with a whole lot of white 24-gauge wire.

I'm a big believer in color-coding your jumpers, so I mark the white wires with a Sharpie once I get them in the board. It's fast, easy, and a lot cheaper than buying a dozen different colors of wire.

Here's the wiring for the breadboard.

This project uses six LEDs.

We'll use Arduino pins 5 through 10 and header pins 2,3,4,6,7,8 for the LEDs, and use header pin 1 for ground as before. The pin mapping looks like so:

5 2
6 3
7 4
8 6
9 7
10 8
GND 1

Header pin 5 is still free, so to make the breadboard wiring a little simpler (and to demonstrate daisy-chaining on the patch shield), we'll add a redundant ground connection.

Here's the patch on the shield.

And the wiring on the breadboard. Having the redundant ground connection means we don't have to run a jumper from one rail to the other.

Note how you can tell, at a glance, which wire on the breadboard corresponds to which wire in the patch. Color-coding your jumpers is A Good Thing.

```void setup () {
for (int i=5 ; i < 11 ; i++) {
pinMode (i, OUTPUT);
}
}

void loop () {
for (int i=5 ; i < 11 ; i++) {
digitalWrite (i, HIGH);
delay (300);
digitalWrite (i, LOW);
}
}
```

Now that the wiring is done, all we need to make the lights blink is some code for the Arduino.

If you've wired everything correctly, and your Ethernet cable is terminated correctly, the code to the left should make the LEDs blink red-yellow-green on one side, then the other.

# WARNING

It's possible to wire everything correctly and still have the LEDs blink in the wrong pattern.

You may have what's known as a crossover cable.

The 10Base-T standard specifies differential signaling, which Bunnie explains better than I possibly can. The upshot re: Ethernet cables is that network cards expect to transmit data on pins 1 and 2, and receive data on pins 3 and 6.

That doesn't work if the cable connects pin 1 of the left terminator to pin 1 of the right terminator. Switches and network hubs swap the TX and RX signals internally, but if you just plug a network cable between two computers things can get wonky.

A crossover cable swaps the two pairs within the cable itself, which allows the computers to talk to each other directly. It also guarantees that someone will eventually plug the wrong kind of cable into the wrong socket, thus perpetuating a small but significant market among network administrators for Guinness, Aspirin, and 9mm ammunition.

Most newer network cards can tell when the other computer is trying to send data on pins 1 & 6 and will adjust automatically, so crossover cables are becoming a thing of the past. You still might run into one though, especially if it's that one in the bottom of the drawer that nobody's using for anything else.

If the LEDs are just blinking green-red on pins 2 and 4, you have a crossover cable. Mark it as such so you don't get caught by it on a more complicated project, or just give it to someone you don't like.

# Second Warning:

(hat tip to philb from the Adafruit forums)

If you're working directly with the wires in a cable, the row numbers on the shield don't match the pin numbers of the 8P8C jack.

The pin mappings from row numbers to cable numbers (and actual wires) are here.

Being able to tell if a cable is wired properly is useful enough that I've built a version of the circuit on prototyping board.

It uses an 8-pin chip socket to connect to the breadboard header.

The pins of the header are designed to fit across the center of a breadboard. The center of a breadboard is designed to accomodate a standard .1" DIP integrated circuit. Chip sockets are also designed to fit a .1" DIP IC, so the header fits in a chip socket.

See?

I wire a fair number of Ethernet cables, and it's all too easy for a couple of wires to switch places as you slide them into the terminator.

This assembly gives me a fast and easy way to verify cables while I still have the tools in my hand.