SPI interface with 7 segment LED

Hi All,

I am currently trying to interface with a 3 digit, 7 segment LED display. I am not having any success. Currently I have the display lighting up, it's just not doing what I want it to do. Here is the code I'm using and the data sheet for the display... Any suggestions?? I can use all the help I can get.

Thanks

#include <SPI.h>

const int ssPin = 10;
                 //1,2,3 are D.P's respectively
                 

                 //0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 
int dataArray[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};


void setup() {
  pinMode(ssPin, OUTPUT);
  digitalWrite(ssPin, HIGH);
  
  // pinMode(11, OUTPUT);
  // pinMode(13, OUTPUT);
  
  // digitalWrite(11, HIGH);
  // digitalWrite(13, HIGH);
  SPI.begin();                                                    //  Initialize SPI parameters
  SPI.setBitOrder(MSBFIRST);                              //  MSB to be sent first
  SPI.setDataMode(SPI_MODE3);                          //  Set for clock rising edge
  SPI.setClockDivider(SPI_CLOCK_DIV64); 


}

void loop() 
{
  digitalWrite(ssPin, LOW);

  for (int x=0; x<35; x=x+1)
  {
    SPI.transfer(dataArray[x]);
  }

  digitalWrite (ssPin, HIGH);
}

led_test3.ino (946 Bytes)

LTM-8522HR.pdf (90.9 KB)

spector:
Currently I have the display lighting up, it's just not doing what I want it to do.

What do you want it to do?

Hi, Thanks for your response!

Eventually I need it to output a scaled value from 0 to 999 based on the position of a pot. Obviously first things first so just make it display a simple number or count from 100 to 110 would be fantastic.

You're sending 35 bytes - you only need to send 5 bytes, or 40 bits.
See the description on page 5.
The first byte sent out needs the upper 5 bits to be 00001xxx where xxx will be 3 of the 35 bits remaining.

Thanks CrossRoads!

Take me back to the basics. How do I send bits instead of bytes then?

You're awesome, thank you!

Well, you can send it bits, so you just need to consult the datasheet to see what effect those bits have. For number display routines, there are so many you can take from open source projects and adapt. Just don't stop with the first library you see, check out a few. I'm not being more specific because you seem to have assumed the burden of writing a driver. I did this for an unknown LCD display - I only had a library for the driver IC, but no map for the segments and digits. It can be done. Don't deprive yourself of seeing what others have done. Seven segment code is very common.

Thanks Aarg,

All the libraries that I've found use more of an analog approach. A pin for each segment and a pin for each digit. This obviously wont work for my serial display.

spector:
Thanks Aarg,

All the libraries that I've found use more of an analog approach. A pin for each segment and a pin for each digit. This obviously wont work for my serial display.

Setting the segments is only a small part of the task. Really, all you need to do is bury your nose in the documentation. It will get you there faster than asking here, unless someone has specific knowledge of the chip. It's sufficiently complicated and detailed, that the best response would be the actual code. But that is for you to write.

If you have more specific questions about interfacing, it would certainly be possible to answer them individually.

Also, I know of and have used libraries for TM1637, TM1638, 74HC595 and many other intelligent LED controllers that are written for Arduino. Not just direct drive.

Thanks Aarg,

Yes, I agree that is only a small part of the problem but I obviously need to start there. If I cant communicate effectively with the display then manipulating one of those libraries will be very difficult.
Do you remember any of the libraries that you've used in the past?

This is why I recommend some alone time with the IC data sheet. Also see reply #3

spector:
Thanks CrossRoads!

Take me back to the basics. How do I send bits instead of bytes then?

You're awesome, thank you!

When you send a byte, you are sending 8 bits.