8×8 LED matrix control on an Arduino Mega

Created 31 March 2009, edited 1 Nov 2020

Once you’ve mastered microcontroller programming, you might be tempted to control a lot of LEDs.  Lots of people have this desire once they master the basics. Many microcontrollers have a limited number of output pins, however, so you might think that limits how many LEDs you can control.  I’ve written about a few different methods around this before in chapter 14 of Physical Computing and in this blog.

By matrixing your LEDs, you can control many more than the number of pins you have.  For example, with the Arduino Uno and earlier models, you had up to 20 digital outputs (13 labeled digital I/O 0 through 13, plus the six analog outputs, which double as digital I/O 14 through 19).  With 16 of those, you can control an 8×8 matrix of LEDs.  That’s 64 LEDs.  With the Arduino Mega, you have 54 digital I/O pins, so you can control a lot more.  This example uses 32 of them to control 2 8×8 matrices, for a total of 128 LEDs from one controller.

To make this example, you’ll need:

  • Arduino Mega
  • Breadboard or prototyping shield. 
  • 8×8 LED matrix.  I got mine in a surplus shop in China, but you can also get them from most electronics retailers
  • male pin headers
  • female pin headers
  • Wires

Step 1: Figure out the LED Matrix pins

Continue reading “8×8 LED matrix control on an Arduino Mega”

Controlling Inkjet Printers from a microcontroller

There was an interesting thread on the Sketching in Hardware mailing list a while back on how to control an inkjet printer.   Wendy Ju started the discussion. Following are some of the links from that thread:

A closed, proprietary portable printer:  Xyron Design Runner

Nice explanation of how inkjets work and how to control them in general. Link submitted by Scott Minneman

Instructions for now sold-out Parallax Serial Inkjet Kit (which does include inkjet cartridge pinouts for the HP 51604A Black Inkjet Cartridge, as well as board schematics, parts and instruction routines for  writing to the cartridge). Even without the device, Parallax’ documentation is handy.

Instructions on how to build your own DNA microarrayer using commercial off-the-shelf parts, including inkjet technologies.  The last two links submitted by Wendy.

Haven’t had occasion to use these yet, but they seem handy.

RFID to Web Interface

This tutorial introduces a Processing interface sketch provides a GUI for the command-line interface written into the Arduino RFID example. You should read that tutorial first. The sketch shown here also allows you to upload tags it reads to O’Reilly’s Emerging Technology Conference attendee portal, and retrieves the resulting profile. The API for this was written by Edd Dumbill. The Processing sketch retrieves RFID tags from the Arduino reader serially, then  passes the tag via a HTTP request to a PHP script on a remote server, shown below,  that adds an authorized login to the O’Reilly site.

Caveat: this tutorial was written specifically for the RFID workshop at Etech 2009.  If you’re doing this on your own, the uploader won’t work because your tags won’t be associated with records in the O’Reilly database, and the PHP script that it calls probably won’t be active on my site anymore.  But you could build your own version on your own server. The PHP code that follows below gives you a start on that process, and the Processing code below can make a HTTP call to any web address you give it.

The entire sketch can be downloaded here:

rfid_uploader_0002

Continue reading “RFID to Web Interface”

Arduino-based RFID reader

This tutorial shows how to make an Arduino-based RFID reader that reads Mifare tags and stores them in EEPROM. It is a modification of Alex Zivanovic‘s code on Tinker.it. Thanks to Alex and Massimo Banzi for the reference. Once you’ve got it running, go on to the RFID to Web example, which provides a Processing interface sketch provides a GUI for the command-line interface written into the Arduino code.

The entire sketch can be downloaded here:

arduino_rfid_reader_0001

Continue reading “Arduino-based RFID reader”

Multiple time stamp checks on a microcontroller

Sometimes you need to manage multiple events with a microcontroller that all require different timing.  For example, you might want to control a servomotor (which requires a 20 millisecond delay), blink an LED once a second, and read some sensors (which should be read as frequently as possible.  One way to handle this is to keep track of a time stamp for each event.  You constantly read the millis() and if enough time has elapsed since the last time a particular event occured, you do it again.

Continue reading “Multiple time stamp checks on a microcontroller”

Using an Accelerometer to Sense Which Way Is Up

ITP just got some nifty flat panel mounts that can rotate 360 degrees. They’re very easy to move, it takes only one hand. When I saw them, I thought, “what good is a rotating mount if the content on the screen can’t rotate too?” So I came up with a little system to sense the screen’s rotation. Here’s how to turn those screens into a very big iPhone. Thanks to Michael Dory for his help in coding this and Dan O’Sullivan for the final clue.

The screens have a mac mini mounted on the back to display digital content. I added an Arduino with an accelerometer mounted on it to sense the angle of the screen’s rotation, then sent that data into Processing.  This example doesn’t do much, but the code can be re-used for any Processing application that needs to know the screen’s rotation.

Rory Nugent modified my existing code and made it much better.  I’ve incorporated his changes here, thanks Rory.

Continue reading “Using an Accelerometer to Sense Which Way Is Up”

Sensorbase datalogger

Sensorbase.org is an open data repository run by the Center for Embedded Networked Sensing at UCLA. It’s a database of sensor databases. You can upload datasets to it, and you can browse other datasets as well. If you’ve never set up a database before but are interested in logging sensor data, it’s a good tool to get started. If you know what you’re doing already and you need to log a lot of sensor data, or compare it to similar work from others, it’s a convenient tool.

Since I like working with sensors and microcontrollers connected directly to the Internet, I thought it would be useful to be able to put data directly into Sensorbase from sensors connected to a microcontroller, without a personal computer in between.

Continue reading “Sensorbase datalogger”