Product Review: Charlieplexed SparkFun 8×7 LED Array

abccharlieplexedledsanimatedI recently picked up the new SparkFun LED Array – 8×7 to try out some hardcore charlieplexing, and so far it’s been working great.

Quoting Wikipedia, charlieplexing is

“…a technique for driving a multiplexed display in which relatively few I/O pins on a microcontroller are used to drive an array of LEDs. The method uses the tri-state logic capabilities of microcontrollers in order to gain efficiency over traditional multiplexing.”

Charlieplexing itself is a simple idea and can be an extremely efficient way of making an LED grid. However, laying out the wiring of a charlieplexed grid, whether on a breadboard or a PCB, can be complicated and require a bit of thinking. It’s easy to layout a grid with 12 or 20 LEDs, but once you start trying to make grids with 30 or more LEDs, it gets a little crazy.

I love SparkFun’s 8×7 LED Array because it eliminates the need to go through the long process of designing and wiring together the grid. Plus it’s in a neat compact module that can be easily embedded. Out of the box, all I had to do was solder on headers and plug it directly into the digital pins on my Arduino. I didn’t need to wire any external resistors, as they’re already built into the board.100_5200

SparkFun has made an Arduino library for controlling the array that allows you to easily write text and draw shapes and do other interesting things on the grid. However, I wanted to use my array with my Raspberry Pi’s GPIO for the purpose of making an archaic internet-connected game system. I’ve written a single-file class in Python 3 for controlling the array with the Raspberry Pi’s GPIO, called pythonic-charlie, and you can find it here (my first legit GitHub repo! Woot woot!). It’s still under development, and still has bugs that need smoothing, but it allows you to display a list of coordinates, test the grid to verify that it’s wired properly, and display a neat little screensaver. I’m currently working on something that will display text. example-wiring

If you ever wanted to learn how to charlieplex LEDs, SparkFun’s 8×7 LED Array is a really great place to start.



Tic Tac Toe Arcade Game with Raspberry Pi

tic tac toe arcade game circuit layout
Final layout of my tic tac toe game

In the event of the Raspberry Pi’s 4th (1st) birthday, I’ve been working on a tic tac toe arcade game using the Raspberry Pi’s GPIO with Python. Basically, a human player battles against the computer on a 3×3 LED grid. The player uses a pushbutton 4-way keypad with a ‘select’ button to play. I also added a speaker and coded some neat sound FX!

Below is a demo of the game:


parts to tictactoe arcade game raspberry pi
Parts used for the tic tac toe game

The hardware for this project is pretty basic:

  • Raspberry Pi
  • 9x green LEDs
  • 5x pushbuttons
  • Speaker
  • Trim potentiometer
  • 9x 330Ω resistor
  • 5x 10kΩ resistor
  • Adafruit Pi Cobbler with ribbon cable

    wiring diagram
    Wiring schematic for tic tac toe made with Fritzing

LED Grid Diffuser

In order to make the playing experience more pleasant, I designed a 3×3 grid LED light diffuser and 3D printed it so as to make the light from the LEDs less blinding. It also keeps the LEDs lined up nice and covers some of the wires up too!

Computer AI

This was actually my first experience dealing with any computer AI, and I discovered that it is quite fun! I designed it so it has four logical steps:

  1. First, if there’s any move where the computer will win (i.e. the computer already has two in a row), the computer will play that move.
  2. Second, if the player could win on the next turn, the computer will block it.
  3. Third, if the center of the board hasn’t been played, the computer will play the center.
  4. Finally, if none of the options above are applicable, the computer will play a random move not already played.


For the software, click here. It’s written in Python 3 with the RPi.GPIO library, and it’s actually the longest bit of code that I’ve written as of yet. 🙂

Here’s an extra video with more info about the project:

building the tic tac toe game
Building the final prototype for the tic tac toe game
closeup of tic tac toe circuit raspberry pi
Closeup of LED grid and buttons

Drum Set with Raspberry Pi – Part 1

This is my prelimnary sketch of the drum kit. It's seriously sloppy.
This is my prelimnary sketch of the drum kit! It’s kind of sloppy.

I like music. I like tapping on things with either my fingers or random objects to get a rhythm stuck in my head out in the world. Since my incessant tapping seems to annoy everyone around me, I’ve decided to make my own fake drum set with the Raspberry Pi! I’ll be able to bang on it as much as I want, and maybe it’ll sound more musical than finger-tapping!

I was inspired to make a drum set after seeing some old large cans after my mom had cleaned up the basement a bit, and I figured they could double as drums. I also figured that I could rig my Pi to play audio whenever each ‘drum’ is hit.

I’ve already made a breadboard prototype with all the components, and I have written software in Python 3 that will likely drive the finished project. Since the software is mostly done, now I’m mainly concerned with building the physical project.

This is the prototype breadboard circuit for the drum set. Each button and LED corresponds with a drum.
This is the prototype breadboard circuit for the drum set. Each button and LED corresponds with a drum.

Here’s some details and components about my drum set:

  • Raspberry Pi: Since this project doesn’t require much processing power and I need at least 20 GPIO, I’m most likely going to use my B+ unless I can obtain a Pi Zero soon.
  • Four RGB LEDs: These will be placed inside each drum and will be constantly lit when the kit is in use, and will change color every time the drum is hit. The RGBs hog up the GPIO pins (12 total) and I could just use two single color LEDs in each drum to reduce the total GPIO pins used down to an amount where I could use the Model B Raspberry Pi as opposed to the B+.
  • The “Drums”: AKA the peanut canisters, will be lined up in a row and wired to four digital inputs.
These are the four cans I found, with a Raspberry Pi to scale.
These are the four cans I found, with a Raspberry Pi to scale.
  • Drumsticks: These will probably be makeshift dowels with a padded metallic tip wired up the shaft of the drumstick and connected to ground. Every time the drumstick touches the top of the drum, the pull-up resistor will connect to ground and therefore read low. That’s the simplest way I can think of to sensor read when the drum is tapped, although the idea of each drumstick being physically wired to the unit is cumbersome. I could use some sort of capacitive sensing, but I’m not sure how to do that digitally or easily with the Pi and I would need to do some research and experimentation. It would also be kind of neat to make the drums sensitive to hand-taps.
  • Speakers: The Pi will be wired to one or two speakers via the audio jack that will play a drum sound effect every time the drum is hit. I have a of couple options with the physical speaker: I can make homemade speakers to embed in the drums, attach an old external speaker, or just leave the Pi’s audio output jack accessible from the outside so that the audio output can be decided at the user’s discretion, whether it be headphones or speakers. However, each option has disadvantages; homemade speakers are cheap, simple, and embed-able, but have an extremely low volume level certainly unsuitable for hard core drumming. Standard external speakers, while nice and loud, are either clunky or require external battery power, which makes them hard to embed. Finally, leaving the audio jack open to the user might reduce the drum set’s portability.
  • Audio: The drum sounds effects themselves are actually .wav sound files played by the software. I decided to use the sample drum effects files used in Sonic Pi since there is a good variety. Because every Pi running Raspbian has Sonic Pi installed, the software will transport across any image of Raspbian, forgoing the need to download any .wav or .mp3 files along the code. I might in the future compile my own set of drum sound effects, but for now Sonic Pi provides plenty of variety.
  • Volume Buttons: The drum kit will have two buttons to control volume up and down.
  • Software: I wrote code in Python 3 using the RasPi.GPIO module.
  • ‘Soundschemes’ and ‘Colorschemes’: Since I’m using RGB LEDs and an audio mixer, there are an infinite amount of colors and sounds that can be produced. I’m adding a button to the drum kit that changes the ‘soundscheme’ or the drum tones that are played. Each soundscheme contains four related drum tones. For now, I just picked random Sonic Pi .wav files to make three mock soundschemes. I also added ‘colorschemes’ where a button can change the LED colors of each drum. This function might be removed in the future.

It might be a few weeks before I finish this. Stay tuned for part 2!

Reflections on Raspberry Pi Zero

If you’re into Raspberry Pi, then by now you’ve probably heard of the recent announcement and release of the newest RasPi model: the Raspberry Pi Zero, which costs a mere $5. Even better, the Zero is included with every printed copy of this month’s issue of the Magpi, making it the first computer ever to come free with a magazine! I think I’ve managed to convince my mom to bring me to Barnes & Noble to get a copy of the magazine when it hits the States in a few weeks.

Anyway, I wanted to write a reflection on how the Pi Zero could become a technological and educational game-changer even more so than the original Raspberry Pi models have been. It might sound kind of nostalgic and dramatic, but hey… I gotta say what I gotta say.

When the original Raspberry Pi model came out in 2012, the world got a cheap computer that would help educate kids in computing and making. Since then, the Raspberry Pi has become one of the ultimate tools of the maker, and its found its way into both proprietary applications and the hands of young kids who learn Scratch. The Raspberry Pi’s popularity derives from both its cost and versatility. And now, not long after the second generation Pi 2 was released, the miniaturized Pi Zero enters the scene at the same price as two cups of coffee. As far as computers that anyone can use, the Zero is by far the cheapest.

The most obvious of the Zero’s features is its cost. It’s a computer  that only costs $5, so anyone can have one to use. It costs less than even the nano versions of standard maker microcontrollers like the Arduino. It’s certainly no longer too expensive to give every child in the world (including kids in third-world countries) a computer to learn on.

Another more subtle impact of the Pi Zero is how it transforms the computer from, well, a computer into a component. Makers and proprietary prototypers alike will reach for the Pi Zero in the way they reach for wires, breadboards, and LEDs. The Pi Zero turns the computer into a mainstream building material. Certainly if we can make a $5 computer, we can also make a new plethora of other cheap technology building component staples.

In my opinion, the Raspberry Pi Zero is going to end up being a critical point in the development of primary education, the power of makers, and computing-for-everything. Going from a $20 computer (model A+) down to a $5 computer, even if it’s a minimalistic computer in some respects, is a giant leap. At the very least the Pi Zero is a testament to the rapidly improving cost-optimization in electronics production and design.

Homemade Raspberry Pi Case

pi case by itself raspberry pi model b

So a while back I was thinking of making a new case for my Raspberry Pi and now I’ve finally gotten around to finishing one!

Items I used:

  • White cardboard box that my RPi Model B came in, so it was already sized to shape
  • 1/4 ” thick anti-static foam salvaged from the hard drive section of an old computer tower
  • Four rubber end caps from a Meccano Erector set to use as rubber feet for the case
  • Silver spray paint
  • Red spray paint
Parts used to make the case.
Parts used to make the case.

This was a make-it-up-as-you-go kind of project for me. I first cut all the peripheral holes one at a time, starting with the USB and Ethernet ports. Then I cut the foam to size and cut a big ventilation hole in the bottom of the case directly underneath the Broadcom chip.

The artistic part came next. I spray-painted the entire case silver to give it a metallic look and used black paint and a crumpled paper towel to give it a sponged, scratched-up look around the sides. I also added the visage of the Raspberry Pi logo using red spray paint and a 3D printed template of the logo. It didn’t come out too good maybe because I jiggled it a bit during spray-painting and didn’t block it properly. It goes with the sturdy-used-tech theme of the case I think though.

 The bottom of the case, with the big ventilation hole and the rubber feet.
The bottom of the case, with the big ventilation hole and the rubber feet.

The last step was adding the rubber feet and putting it into action! The only problem I noticed is that it does get a little warm in the case. I probably should’ve added more ventilation holes in the bottom since the anti-static foam traps the heat. This isn’t really an issue for me, though, because I don’t run my Pi for very long periods of time.

raspberry pi case in action model b
The case in action.

Cheap Pi Power Using AA Batteries Experiment

Raspberry Pi_Rechargeable Battery Test_pic 1My latest experiments involves attempting to power a Raspberry Pi using rechargeable AA batteries. I wanted to see if I could successfully run Raspbian with the standard peripherals using only a pack of four AA batteries and a modified micro USB cable, without any regulators.

The Raspberry Pi is built to run on 5V with a tolerance of ±5%, or a range of 4.75 – 5.25 V. The total voltage of your average AA is 1.5 V, so a total of four standard non-rechargeable AAs adds up to 6V, which is too much for the Pi without using a 5V regulator. However, NiMH AA batteries typically have a voltage of 1.2V, so four of them adds up to 4.8V, which is in the Pi’s operating range.

Although the rechargeable AAs I have were rated for 1.2V, they actually ended up being 1.3V when charged, so that put it at 5.1V, still within the Pi’s operating range.

The funnest part of this whole experiment was modding the micro USB cable. I cut off the cable from an old wall charger and stripped the wires. Unlike a regular micro-to-standard A cable, which has white and green data lines plus the red Vcc and black GND,  a micro USB charger only has the black and red because obviously you can’t transfer data from the wall to a device.

Raspberry Pi_power experiement aa batteries

I first set up my Raspberry Pi Model B+ with Raspbian with the standard mouse, keyboard, and monitor, and set up the rechargeable batteries. As soon as I plugged it in, it immediately entered the endless reboot cycle, and didn’t end up completely booting at all.

The next test was with my Raspberry Pi Model B. Again with the same peripherals and Raspbian image, I plugged in the batteries, with a little more success. The Model B booted successfully, and I got it logged into the desktop. I left it alone to see how long the Pi could be sustained. Exactly 15 minutes later, the Pi entered the reboot cycle.

So powering the Raspberry Pi models B and B+ wasn’t too successful. Only the model B was able to properly boot and it only ended up lasting 15 minutes, and if I had been running some software or circuits, it probably would have lasted much less.

I might try this test with regular batteries and a 5V regulator to see if the results change. If I were using a model A or A+ Raspberry Pi I would probably have better results because those models have less power requirements. The overall purpose of this experiment was to see if I could cheaply power my Pi using only batteries with no external circuitry.

So the results are:

  • Raspberry Pi Model B+…Failure, failed to successfully boot
  • Raspberry Pi Model B…Success, booted and stayed on for 15 minutes

Please note that if you try to power your Pi with batteries, be aware of the voltages you’re using. While the Pi might be able to handle 6V input, peripherals like mice and keyboards, which directly receive the Pi’s input voltage, can’t.

Project: XL Seven-Segment Display

seven-segment displayseven-segment display









Here’s the perfect amateur maker project: a self-built giant seven-segment display that will awe all those who watch it in action! You only need a Raspberry Pi and a handful of regular LEDs and resistors, plus a breadboard. You can 3D print a case or you can use a paper template printout of the display. This project is versatile, I’ve provided Python 3 code for the Raspberry Pi, but you could use anything like an Arduino Mega or Beaglebone, you’ll just have to write your own software. Why, you ask, couldn’t I just use a standard 3 cm $0.99 seven-segment display? Because you can’t DIY and it’s not half as cool!

BoM (Bill of Materials):

  • 21 red 5mm LEDs
  • 21 330 ohm resistors
  • Raspberry Pi B+ or Pi 2 with peripherals
  • Adafruit Raspberry Pi Cobbler Plus w/ ribbon cable (not required by HIGHLY recommended)
  • Full-Size breadboard
  • 3D printed seven-segment display case with seven segments OR if you don’t have a 3D printer, this paper printout here (I recommend cardstock or similar for opacity and durability) with a standard paper holepunch
  • Assorted wires and jumper wires
  • Small piezo buzzer (completely optional, just if you want countdown sound effects)
The wiring with the 3D printed segments
The wiring with the 3D printed segments in place
seven segment display wiring
The bare-bones wiring display











  1.  The first step is to properly position the LEDs and their power and ground connections. Start by putting the Adafruit T-Cobbler to the far right side of the breadboard, all the in the last set of holes.
  2. Next, we’ll wire each segment one by one. Refer to the diagram below, just starting with the LEDs and their resistors to ground; in the next step we’ll add the jumpers to the pins. The center three segments require  a bit of maneuvering to get the resistors and jumpers into place. Make sure not to clip the resistor leads too short, and it may be helpful to use some needle-nosed pliers to get the resistors in place without ripping up other LEDs.fritzing diagram
  3. Finishing up the LEDs and their resistors to ground, now we can wire each LED to a pin on the Raspberry Pi. You can either copy the wiring shown here, or you can make up your own wiring. If you do your own pin wiring, make sure you keep careful track of which pin is part of which segment, either on paper in some working code variables.
  4. Optional step: If you want to add a small piezo buzzer for countdown sound effects, now’s the time. Connect it to pin 21 and span it directly to the ground rail. Or, if you did your own pin-numbering connect it to any free pin.
  5. Now for a bit of wire management: make sure all your jumper wires are underneath the LEDs so that they don’t get in the way of the segments and casing.
  6. If you have a 3D printer: Print the casing and seven segments from here. Test fit each hole in each segment with an LED to make sure an LED fits. Put a segment over each set of three LEDs, and fit the casing over all the segments. You’ll have to bend the LED leads a bit so it fits, and the first time you put the casing on will be a bit of challenge.
  7. If you don’t have a 3D printer: Print this seven-segment cutout here. Cut it out on the dotted lines and then holepunch each symbol. Now fit the cutout over the LEDs. Note that it’ll be a bit tough to fit it over the LEDs the first time; you’ll likely have to bend the LED leads quite a bit to get it to display side view
  8. The hardware is all finished! At this point the display should be making you giddy with happiness, but it’ll be even better once it’s got some software! Warm up your Raspberry Pi and open up your favorite text editor to write some Python code!
  9. Check out the code here. It’s got lots of comments that explain how the code works. Make sure if you wired your pins differently, you change the variables to reflect your wiring. When you get the code running you’ll be able to display numbers, do a 9-0 countdown, and do some cool animations!
  10. Troubleshooting: if some of your LEDs aren’t working double check they could be burned out. Replace them and if they still don’t work check your connections to the pins. Finally, check your variable assignments; one error can make the whole display act strangely.
  11. Now you’ve got a working XL seven-segment display, with five GPIO pins to spare! Now you can stare at the mesmerizing numbers all day…

The Origins of This Project Plus Future Developments

I was inspired to make this after seeing some 3D printable large seven-segment displays on Thingiverse. Because my Printrbot Play 3D printer has such a small build dimension, I designed my own, slightly smaller display and got to work with my Raspberry Pi. I made the display small enough that you can simply use a breadboard, which makes it different from other large seven-segment displays.

There is plenty of room in the back of the 3D printed case so that you can make a custom PCB if you like (I won’t attempt that now; I still have to develop my terrible soldering skills!), and there’s screw holes so you can also mount it to something. I’m currently working on a charlieplexing solution to reduce the pins used for the display from 21 down to 6. That way I’ll be able to use an Arduino Uno, add another display (another display would add a whole lot of potential), or add more components.

seven-segment display