8×32 LED display with Arduino – rolling display

Following on from my basic LED display test, I have moved on to produce an arduino sketch which might be useful to folk. Basically it reads in an analogue value and then converts this to a bar graph display which scrolls across the 8 x 32 LED matrix from Sure electronics (see previous blog post).

A short (very bad quality) film is shown here:

The display can only show 9 values (8 LEDs plus totally blank = 9 states). The incoming value from the analogue read is 0-1023 (a 10 bit number). Therefore this number must be converted into much lower resolution.

The code is written as follows (pseudo-code):

  1. Read in the analogue values
  2. Convert 10 bit number into 4 bit number (reduce resolution)
  3. Create the data to display on the far right hand side column
  4. Move all the columns along the display by 1
  5. Wait (to control the scroll speed)
  6. Repeat from step 1

The LED matrix is set up in a number of blocks. For the 8×32 matrix there are 64 blocks, with an address from 0 to 63. Each block is 4 LEDs which is a 4-bit number. Looking at the matrix from the front, the addresses look like this:

0  2  4  6  ……  62

1  3  5  7 …….  63

So writing (binary) 1111 to address 0 and address 1 would turn on all 8 LEDs in the first column. This info helps us to create the actual data to display.

We want to create new data to send to the display. All data enters from the far right hand side of the screen so it placed into address 62 and address 63.

To create the two 4 bit numbers to send to address 62 and 63 I use a mask and OR the result with the mask.

The range of 0-1023 is broken down into 8 levels, each equal to 1024/8 = 128. The levels are 128, 256,  384 …. 1024. A check to see if the incoming data is larger or smaller than each of the levels. If it is larger then the corresponding LED is set high. This is done using a mask which is shifted each time.This is done for each of the two values which will be sent to the two addresses (62 and 63). Data is displayed in the opposite order to that expected (ie MSB (most significant bit) first), hence why the mask starts at binary 1000 and shifts to 0100 then to 0010 etc.

The data from the display is shifted down the display (i.e. data from address 62 is moved to address 60, 61 ->59 etc. etc.) The data moves down 2 addresses due to the address blocks shown above.

There is a delay which controls how quickly the data scrolls.

This definitely isn’t the most efficient code but it does the trick in a way I understand.

Maybe this code might be useful to others. The sketch can be downloaded here. To use this open the zip file and copy the HT1632 directory to your arduino libraries folder. Open the scrolling_data_matt.pde via arduino sketch. It should all run, but you will need to wire up the Sure electronics LED display as shown at the top of the code.

At present the display only works with one LED matrix attached. I will upload code which will work with all 4 LED matrix attached, or you can try it out yourself.

I will be using this to show varying signals over time such as temperature and power. Good analysis of the incoming data is required for the display to be useful.

Leave a Reply

Your email address will not be published. Required fields are marked *