Adafruit 16x24 red LED matrix (HT1632)

I was trying to use the 16x24 LED matrix from Adafruit with the Particle Photon. I tried uploading the default example from the Adafruit and I can’t seem to get the display to work even though the example seems to upload fine with no errors. The display works fine on my Arduino UNO. Does anyone know what steps I would need to get this library working? The link to the library is below:

Any help or tips on what I should do next would be appreciated. Thanks!

  1. Is your code being flashed (D7 indicating, or other way to tell)? See How to get started?
  2. Could it be 3.3V out of Photon, is a bit shy for a 5V input?
  3. What does " I can’t seem to get the display to work" mean? Wrong characters, no lights, ?

Hi Jack. The answers to your questions are below:

  1. I confirmed that the code was in fact not being flashed when I was trying to upload it in Particle Dev. It was apparently running some old code that I previously loaded and I didn’t see any errors so I just assumed everything was working.
  2. I am using a seperate 5v source to power both the Photon via the VIN pin and also the LED Matrix so I don’t believe that is the issue.
  3. The display does not light up at all and does not appear to turn on.

I am able to flash other programs to the Photon now and when I attempted to load the basic example from the Adafruit library I now get the following error:

avr/io.h: No such file or directory

I’m not sure where to go from here or if this issue is just because the library I am using is not compatible.

1 Like

@Proto, thanks for the detailed information. I am not familiar with that library. Maybe one of the guys that is, will have a suggestion (long weekend tho).

@Proto:

  1. In file HT1632.h, there are a couple of #if(ARDUINO >= 100) conditional compile statements. How did you modify these for the Photon?

  2. If you are using the basicdemo.pde demo code, did you rename it to basicdemo.ino? What did you assign to these values:

 #define DATA 2
 #define WR 3
 #define CS 4

I just received the photon a few days ago so this is all new to me. I have limited experience with creating libraries and I’ve also have never tried to port one over to work with the photon before so I don’t know if I’ll be able to figure it out. To answer your questions:

  1. I commented out the #if(ARDUINO >= 100) and replaced it with #include “application.h”. I’m not sure if this is all I need to do here.
  2. I was attempting to use the basic demo.pde so I renamed the sketch as ht1632test.ino and placed it in a folder called ht1632test with the HT1632.cpp, HT1632.h and glcdfont.c files. (I can attempt to compile the code but I just encounter several different errors). I have not yet changed the values for DATA, WR and CS.

Upon more review, I noticed that this library has several bits of code that are AVR specific some of which I listed below:

–glcdfont.c
avr/io.h and avr/pgmspace.h with PROGMEM macro which would not be applicable for the photon

–HT1632.cpp
__BV macro

I’m not sure what the next step is but I’m sure I would have to update all of these. I am going to take another look tomorrow. Thanks so far for the help!

@Proto, some very basic pointers for porting Arduino libraries can be found here
https://github.com/harrisonhjones/Spark-Ported-Libraries

But at the moment it’s still solely focused on the Particle Core and not the Photon, you’ll get some idea tho’.
The conditional compiling directive for the Photon would be #if (PLATFORM_ID == 6) instead of #if defined(SPARK) (for the Core it’s now PLATFORM_ID == 0).


After having a look at the lib I’m convinced you can manage to port the lib with only the hints from the link above. There is no bare metal programming that would need some major rework of the original code.
But if you should still happen to have problems getting the hang of it, just ask, we’re there to help, when we see your effort.
Any error messages you get after porting would be good to post too.


One bit missing in the link above:

#define _BV(x)   (1 << x) 

Since you haven’t changed the pin assignment, how have you wired the display?
Although it’s discouraged to use the “number-only” pin referencing on Particle devices (rather use the labels printed on the board) it’ll still work when you wire up D2, D3, D4.

1 Like

Thanks very much! That link was super helpful. I was just able to get the test program to work and everything looks good. I also ran the other two examples in the library and they are both working. This is great!

2 Likes

Does anyone has some working code for the Photon here?

@Arne, give this Web IDE app a shot. I used the matrix demo code in this case. I don’t have an HT1632 to test with so you will need to do that.

https://go.particle.io/shared_apps/5e1bc837ab86a600051a962a

Note the following pin assignment which you will need to follow:

#define HT_DATA D2
#define HT_WR   D3
#define HT_CS   D4
#define HT_CS2  D5

Let me know how it goes!

1 Like

It was actually very easy when I got the pins right :smiley:

should the library be availeble in the online editor?

@Arne, glad to see it works! Now that I know it works, I can create a library for publishing on the Particle Web IDE, possibly this weekend. :smile: