When I was 10 years old, I visited my grandfather’s house a lot. I remember these visits like they were yesterday, even though they were *cough* years ago. I used to sit in awe of his garage. The man was a maker before that term had the connotation it does today. He had oscilloscopes, wiring diagrams neatly tacked to walls, thousands of little drawers filled with tiny little pieces that I didn’t recognize then but I know today as the basics of electronics – resistors, lights, buttons, soldering wire, and myriad components.

He had patents for devices he invented like the Kensico Air Mite – a device that could listen to the radio traffic of planes as they flew overhead. When I was bored, instead of sitting me in front of the TV, he sat me in the middle of his garage with a hammer, nails,  and wood and said, “Build something“. So much of what makes me the man I am today was inspired by him, including my insatiable desire to build something.

So when I opened by Raspberry Pi 2 (the quad core, 1GB RAM successor to the original) I was excited. It took me back to those days in my grandfather’s garage, making crap I knew wouldn’t work but it didn’t matter. The fun was in the building, in the act of creating something new with my own hands, my own intellect.

I fired it up with the install image that shipped from Adafruit, I wrote 4 lines of Python code, and then I was hit in the face like a kid on Christmas morning who got a lump of coal instead of that He-Man figure he’d been waiting for all year. The console rejected my code, complaining that “This module can only be run on a Raspberry Pi!“. I am running a Raspberry Pi you shitforbrains! I yelled at my tiny little computer. When the white-hot rage finally cooled enough to allow me to type, I hit the interwebs and found that even though these devices are supposed to be shipping to kids and educators and beginners, most of them ship with horribly outdated boot images that don’t even work properly with the GPIO boards (I’ll discuss that later, but that’s basically the thing that lets you control devices and components… you know, the reason I bought the Pi2). Shame on you, Adafruit. That’s just pure laziness. I downloaded NOOBS (New Out of the Box Software) from here and created my own replacement boot image on an SD card. The first “normal” teenager who has to do that is going to walk away and never finish.

Now, with my new (properly functioning) boot image in hand, I connect up my breadboard as shown in the following picture:

Raspberry Pi 2 Wiring with a Cobbler and Breadboard

Raspberry Pi 2 Wiring with a Cobbler and Breadboard

For those of you who don’t know what’s going on here, I’ll explain. The rest of you can skip the next few paragraphs.

A breadboard is basically a replacement for soldering. Instead of permanently connecting the pins on your Raspberry Pi’s GPIO (General Purpose I/O) board to LEDs, motors, and sensors… you can just plug stuff into the breadboard for prototyping. What you see in the picture above is a ribbon cable (basically 26 wires stuck together) coming off the GPIO board and sticking it into the breadboard. This basically lets me act as though all those pins are connected directly to the breadboard.

The ribbon cable is hiding it but I have male-to-male jumper wires plugged into the breadboard holes adjacent to the pins in the cobbler (the chip at the end of the cable) for pins 7, 11, and 13. In my case, I’m using the board numbering system for pins which starts with pin 1 at the top left, pin 2 top right, and so on until pin 26 at bottom right. There are other, more complicated, numbering systems that have more meaning to actual hardware people but I’m not really a hardware guy so I’m using the “easy mode” numbering system.

From pin 7, I run a jumper wire to the same row as where I have plugged in the positive (long leg) lead on the end of my red LED. I run a similar wire from pin 11 to the row where I have the positive leg of the green LED. Finally, I hook up the blue LED to pin 13. I then run a resistor from the negative leg to the ground (the black vertical rail on the far edge of the breadboard). Because I have this same ground rail plugged into a ground pin on the cobbler (pin 6 in this case), this is allowing me to complete the circuit. The resistors are, according to more hardware-oriented people than myself, there to drain off excess current so it doesn’t, and I quote, “set the Pi2 on fire”.

As an aside, I chose 7,11, and 13 because they are valid to be used as output. Pin 9 cannot be used as output.

So, with my bread board hooked up and a complete circuit created, I power on my Pi and get into a console mode and I create the following Python file:

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BOARD)
GPIO.setup(7, GPIO.OUT)
GPIO.setup(11, GPIO.OUT)
GPIO.setup(13, GPIO.OUT)

GPIO.output(7, True)
time.sleep(1)
GPIO.output(7, False)
GPIO.output(11, True)
time.sleep(1)
GPIO.output(11, False)
GPIO.output(13, True)
time.sleep(1)
GPIO.output(13, False)

This essentially lights up each of the LEDs for 1 full second, and then turns it off and moves on to the next LED in the line, lighting it up for 1 second, etc.

If you take a look at the following video (QuickTime MOV file), you’ll see a short clip of this in action.

Raspberry Pi 2 LEDs in Action

You might be looking at this and thinking, big deal, this moron turned on some LEDs. Anybody can do that. And, you would be right. Anyone can do that. THAT is the point. The point is that for under $100 of consumer-grade, publicly available parts with no prior knowledge of electronics, hardware, or software, someone can get to the point where they’re writing code that manipulates external components in short order.

While turning on LEDs from a Raspberry Pi might not seem to be that important, the fact that I can write code that can interact with hardware and do so on a remarkably cheap, ultra-portable device with full networking capability is ground-breaking. This is my first foray into the world of The Internet of Things, and I’m pretty damn excited.