Interactively controlled animation on a 64-pixel RGB LED display

OK, enough with this pompous title.

I’ll just show how to hook up a normal potentiometer to PORTC, PIN2 of the ATmega168/328 microcontroller and control which image is displayed on the matrix. This pin works as an analog to digital converter. In Arduino language, this is the “Analog 2” pin, which is referred to in the code just as “2”, used in combination with the “analogRead()” function.

As will be shown in the video, you’d need:

  • One of my boards. “What else ?” ;-)
  • A compatible 8×8 RGB LED matrix
  • Power, I use my battery shield based on the MAX756 DC/DC boost converter
  • 2 AAA cells
  • USB adapter ( from now on I use the ModernDevice BUB board )
  • Arduino IDE V16
  • Example code

The potentiometer is connected to +5V and GND, the swing arm (is that a valid term?) goes to ADC2 and will provide voltages from 0 to 5V. These translate to numbers from 0 to 1023. In the example code there are 9 images stored in an array in FLASH memory (using PROGMEM), so I divide the return value of “analogRead(2)” by 64 and use an if statement to ensure it never goes above 8. The images are addressed by array elements 0 to 8. That’s it.

I won’t go over the other code needed to actually drive the matrix again, as I’ve covered that before. This here is the core of the code. I’ve skipped everything else ( setup(), hardware related stuff, … ), so this code won’t run as is. You can download a valid arduino sketch below.

Here’s the code: potanim.pde

This entry was posted in Arduino., Electronics. and tagged , , , , . Bookmark the permalink.