STP16C596 Shift Register

This tutorial will show how to control multiple LED outputs from a microcontroller using an STP16C596 shift register. The STP16C596 is similar to the popular 74HC595 shift register, but it’s nicer because it can sink a constant current to the LEDs it’s driving. It works slightly differently, however, so this code won’t work exactly for the ‘595.

This is a stub. More explanation will follow, but for now, here are schematics and code for Arduino.

Parts you’ll need:

  • STP16C596 shift register
  • Arduino microcontroller
  • LEDs
  • 1-kilohm resistor

Continue reading “STP16C596 Shift Register”

Tilty ball: Controlling 64 LEDs and a 2-axis accelerometer

This example shows how to control 64 LEDs and read the input from two axes of an accelerometer on an Arduino.  The Arduino used here is a Duemilanove, but it will work on any of the models out there prior to the Duemilanove as well.  This example uses row-column scanning as a way to control more LEDs than you have output pins.  It also uses some of the analog pins as digital I/O pins.

Parts you’ll need

  • Arduino Duemilanove or equivalent
  • 2-axis accelerometer. I used the ADXL335 breakout board from adafruit.com, and only used two axes.
  • 8×8 LED matrix.  I used one I bought surplus.  See this post for details on figuring out your matrix’s pins if you don’t have the data sheet.
  • Breadboard or prototyping shield.  I used the proto shield and tiny breadboard from adafruit.com.

Continue reading “Tilty ball: Controlling 64 LEDs and a 2-axis accelerometer”

A Tale of Two (three) Pongs

Created 2 April 2009, updated 1 Nov 2020

When I start learning a new  platform, I have a simple rule: If you don’t know what to do with it, make pong. What I love about pong is that it’s a simple rule set, easy to understand, and implementable on just about anything with a pixel display.  You can generally implement it in a day or less on any platform. And it’s a great example of engaging interaction.  People understand what’s going on right away, and, when implemented well, it’s just challenging enough to keep you engaged for several minutes at least.  That’s good interaction, to me.

I’m a big believer in starting with the application rather than the platform.  I think you do better work when the tools serve the need rather than the other way around.  But sometimes you get stuck with the assignment to learn a particular platform or tool, and you have to make up a project on the spot.  When that happens, make pong.

As an example of this, I built pong for two platforms yesterday [1 April 2009]: an Arduino Mega with 2 8×8 LED matrices (based on my earlier post), and Processing.  Since Arduino’s programming syntax was based closely on Processing’s, I figured it should be possible to port the code from one to the other pretty quickly. It took about ten minutes to go from Arduino to Processing.  In 2020, I updated this exercise to write the program in p5.js as well. Following, I’ll describe the thought process of putting the game together for all three, as a hopeful aid to beginning programmers.

Continue reading “A Tale of Two (three) Pongs”

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.

Dynohubs: power from bikers

Lots of people are into mechanical generation of electrical power these days, so here’s a nice tip from the guys at Uncommon Projects: dynohubs.  I had a note in my inbox for months that just said “dynohubs, Tarikh.”  So I wrote, and he offered a lovely explanation, and a link:

Dynohubs are cool. They are sort of stepper motors in reverse,
actually sealed in a bicycle hub. They generate AC current which can be
easily rectified and smoothed to DC and (mine anyway) generates nearly 400mA
without significant speed. There’s some minor friction from the magnets but
they’re much better than the old style “bottle” hubs (which are
significantly cheaper).

Dynohub in Uncommon Action!

Perhaps you were asking me because I’ve been meaning to make an instructible
for months about how to power or charge your iphone/device from your bike?

They’re not necessarily cheap. A quick google search for the Shimano 3N71 that Tarikh mentions comes up with prices ranging from $99 – $150.  3W at 6V, that’s half an amp. Not a bad start.

Surplus Center

Mike Olson likes to move heavy things.  So when he says something like this:

Hands down the best site for finding cheap powerful motors is:

www.surpluscenter.com

You can’t search by torque, but they usually have an excellent seclection of powerful gearheads and linear actuators.

I had great results with one of these guys a while back. Probably bigger than what you need, but produces huge torque with very little current. The only problem is that it’s very heavy.

I believe him.  So if you’re looking for motors that can lift heavy stuff, follow Mike’s lead.

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”