SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them

Sounds like you may not have connected it up as you intended to in your previous post. Some of the data and address pins mixed up?

My example code sets A0 & A1 to low, so only the leftmost character should ever appear, but if you accidentally swapped some data and address pins, that would explain it.

Arduino language is indeed C++ with some standard libraries which provide digitalWrite(), pinMode(), bitRead() etc.

OK...got part of it figured out. I had hooked up A0 and A1 into Digital 3 and 4 on the Arduino. I moved them to Analog A0 and A1.

But it is still just cycling through x, y, z and { (One bracket now).

And just the left digit is lit now.

Mike

Interesting....not sure what I did.

I recompiled the code and reloaded it. Now it is scrolling through x, y, z and two brackets starting from the right digit and moving across sequentially....

I moved the A0 and A1 back to pins 4 and 3 respectively on the Arduino because that is how the #define has them.

Anything else I can try?

I really appreciate the help. I am googling the heck out of this too. I'm trying to learn what is going on. I used to be able to code with VisualBasic in Access databases, but that has been more years in the past than I care to remember.

Mike

OK....I disconnected EVERYTHING and started over.

My pin layout is exactly like this"

From SLR2016 to Arduino

1 Write 2
2 A1 3
3 A0 4
4 Vcc 5v
5 D0 5
6 D1 6
7 D2 7
8 D3 8
9 D4 9
10 D5 10
11 D6 11
12 Blank 5v
13 Clear 5v
14 GND GND

The code I am running:

const byte SLR2016_D[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11};

#define SLR2016_A0 4
#define SLR2016_A1 3
#define SLR2016_WR 2

void setup() {

for (byte i = 0; i < 7; i++) {
pinMode(SLR2016_D*, OUTPUT);*

  • }*
  • pinMode(SLR2016_A0, OUTPUT);*
  • pinMode(SLR2016_A1, OUTPUT);*
  • pinMode(SLR2016_WR, OUTPUT);*
    }
    void loop() {
  • for (char c = 'A'; c <= 'Z'; c++) {*
  • digitalWrite(SLR2016_A0, LOW);*
  • digitalWrite(SLR2016_A1, LOW);*
  • for (byte i = 0; i < 7; i++) {*
    digitalWrite(SLR2016_D*, bitRead(c, i));
    _
    }_
    digitalWrite(SLR2016_WR, LOW);
    digitalWrite(SLR2016_WR, HIGH);
    _
    delay(500);_
    _
    }_
    _
    }*_
    And it is back doing the Digit 0, Digit 2, Digit 1, Digit 3 sequence.
    See anything wrong?
    Mike

Yes, I can see straight away what's wrong. You made the same mistake as before! How many elements are supposed to be in that array?

Well....by array, I am guessing you are talking about this line:

const byte SLR2016_D[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11};

That is all the pins I am using on the Arduino....

I've been googling the code for the last few hours. I tried just using {2, 3, 4} and all that does is turn on all the LEDs in the display.

Mike

I just tried:

const byte SLR2016_D[] = {5, 6, 7, 8, 9, 10, 11};

That is only the data pins D0 through D6.

That lets the far right display scroll A-Z with the other three displays to the left completely on.

Mike

Ah-ha! Now we are getting somewhere. So by "completely on" you mean all 5x7 points are lit? I guess that's normal if we don't send any data to that position on the display. And A0=A1=low is the rightmost not the leftmost. Excellent work Mike, I suspect the wiring is now correct!

So next is the scrolling message?

I'm trying! LOL

The first three displays (from the left) change depending on my last attempt at loading code. I've been changing code all morning and loading it. I now know a lot of code that doesn't work :slight_smile:

Right now, I have (from the left) y z y A-Z (scrolling). The y z y has been a little bit of everything and at one time I had them "completely lit" with all 5x7 points lit...

So yeah....let's try a scrolling message.

How about "Mary had a little lamb."

Mike

Ok Mike. Won't have much time to help you tomorrow (I have house guests). So Monday.

Paul

Sounds good. Thanks for letting me know.

Well, my house guests got delayed...

const byte SLR2016_D[] = {5, 6, 7, 8, 9, 10, 11};

#define SLR2016_A0 3
#define SLR2016_A1 4
#define SLR2016_WR 2

char msg[] = "    Mary had a little lamb    ";

void setup() {

  for (byte i = 0; i < 7; i++) {
    pinMode(SLR2016_D[i], OUTPUT);
  }

  pinMode(SLR2016_A0, OUTPUT);
  pinMode(SLR2016_A1, OUTPUT);
  pinMode(SLR2016_WR, OUTPUT);

}

void loop() {

  for (byte p = 3; p <= 30; p++) {
  
    for (byte c = 0; c < 4; c++) {
    
      digitalWrite(SLR2016_A0, bitRead(c, 0));
      digitalWrite(SLR2016_A1, bitRead(c, 1));
  
      for (byte i = 0; i < 7; i++) {
        digitalWrite(SLR2016_D[i], bitRead(msg[p-c], i));
      }
      
      digitalWrite(SLR2016_WR, LOW);
      digitalWrite(SLR2016_WR, HIGH);
    }
    
    delay(500);
  }
}

Well....I have scrolling text kind of....the letters are jumbled.

From the looks of it, I think it is doing that Digit 0, Digit 2, Digit 1, Digit 3 thing yet.

Mike

I fixed it! I fixed it!

I looked at the code. A0 and A1 had the pins reversed.

It works!!!

Mike

Interesting. If I change the text "Mary had a little lamb" to anything else, I get 5 or 6 random characters at the beginning of the display before the text scrolls from the code. It doesn't matter what I use....my name....city I live in....I get them. Even on "Mary" I get one random character.

Would that have anything to do with the spaces between the quotation marks and the words displayed?

Mike

Can we go through this code pretty much line by line and explain what it does? I think I understand parts of it.

PaulRB:
const byte SLR2016_D[] = {5, 6, 7, 8, 9, 10, 11};

This is the data pins D0-D6 to the Arduino pins. I don't understand the [] though.

PaulRB:
#define SLR2016_A0 4
#define SLR2016_A1 3
#define SLR2016_WR 2

This defines the pins to the Arduino. But can this also be used to substitute names. What I mean...instead of typing SLR2016_A0, it could be replaced by a 4 anywhere in the code? If so, what differentiates that? How does that #define tells it it is pins 4, 3, and 2?

PaulRB:
char msg[] = " Mary had a little lamb ";

Pretty simple. The text I want displayed. Per an earlier post, if I change this to anything else, I get a bunch of random ASCII characters between scrolls. Whether it is at the end or the beginning, I don't know.

PaulRB:
void setup() {

Start of the setup routine?

PaulRB:
for (byte i = 0; i < 7; i++) {
pinMode(SLR2016_D*, OUTPUT);*

  • }*
    [/quote]
    I am guessing this is setting the bytes to 7. I don't understand the i++, c++ or any other letter and ++. I've googled the heck out of that.
    pinMode, I am guessing is setting all the Data pins to output? What is the i in the [] for? From my VisualBasic days, I am sure there is a rhyme or reason to all the {} brackets. I know they enclose groupings of the code....
    > PaulRB:
    > pinMode(SLR2016_A0, OUTPUT);
    > pinMode(SLR2016_A1, OUTPUT);
    > pinMode(SLR2016_WR, OUTPUT);
    >
    > }

Hmmmm....another pin mode....setting A0, A1, and WR to OUTPUT.....but....I thought D0-D6 were defined as OUTPUTS earlier? And another bracket...
> PaulRB:
> void loop() {
Start of the loop sequence?
> PaulRB:
> for (byte p = 3; p <= 30; p++) {
>
> for (byte c = 0; c < 4; c++) {
More LETTERS++ and brackets....must have something to do with setting the byte count?
> PaulRB:
> digitalWrite(SLR2016_A0, bitRead(c, 0));
> digitalWrite(SLR2016_A1, bitRead(c, 1));
I've googled the heck out of digitalWrite and I still can't get this. It definitely does something with the address bits in this....

> PaulRB:
> for (byte i = 0; i < 7; i++) {
> digitalWrite(SLR2016_D*, bitRead(msg[p-c], i));
_> * }
_
> [/quote]
> Something to do with bytes....and digitalWrite....and bitRead. No clue on this. None.
>
> > PaulRB:
> > digitalWrite(SLR2016_WR, LOW);
> > digitalWrite(SLR2016_WR, HIGH);
> > }
>
> Now it sets WRITE to LOW and HIGH....why? What does this do?
> > PaulRB:
> > delay(500);
> > }
> > }
>
> When I change that to 200...it goes really fast :slight_smile:
> And evidently the } bracket is the last brackets enclosing something and something...
> Thanks for all the help on this! I'd really like to understand this code better but Google has not been a huge help on this. I hesitate to change much of the code because I am concerned of some magic smoke making an appearance.
> I am sure these displays have a lot more tricks they could do...and I'm sure you could probably write a book answering my questions.
> Mike

Interesting. I got rid of all the funky characters. I changed the 30 in this line to one less digit than the spaces between the quotation marks with the words that I want to scroll. If I went the same number, I got one funky character:

for (byte p = 3; p <= 30; p++) {

for (byte c = 0; c < 4; c++) {

Figured out that the 4 means I have four digits and changing the 3 and 0 makes certain displays not work depending on the number.

Seeing if I can get a second display hooked up today so it scrolls across two of them....but does that mean I need to change something in the code to get two displays going?

Mike

brassbuilder:
Would that have anything to do with the spaces between the quotation marks and the words displayed?

Yes, I deliberately put 4 spaces before "Mary" to blank the display before the "M" of "Mary" appears. The random characters you have seen are memory bytes before the location where the "Mary has a little lamb" are stored. C and C++ to not check if you try to access an array element that is beyond the upper limit or below the lower limit of the character array/string.

brassbuilder:
I don't understand the [] though.

"[]" indicates to the compiler that the variable is an array. Normally you would put a number between the brackets to indicate how many elements the array contains. But because the array is initialised with a list of values, the compiler makes the array big enough to hold the list.

brassbuilder:
This defines the pins to the Arduino. But can this also be used to substitute names. What I mean...instead of typing SLR2016_A0, it could be replaced by a 4 anywhere in the code? If so, what differentiates that? How does that #define tells it it is pins 4, 3, and 2?

Lines beginning "#" are compiler-directives. "#define" are simple substitutions replacing every occurrence of "SLR2016_A0" with "4" for example.

brassbuilder:
Pretty simple. The text I want displayed. Per an earlier post, if I change this to anything else, I get a bunch of random ASCII characters between scrolls. Whether it is at the end or the beginning, I don't know.

See my previous post.

brassbuilder:
Start of the setup routine?

Errr... yes.

brassbuilder:
I am guessing this is setting the bytes to 7.

Don't understand...

brassbuilder:
I don't understand the i++, c++ or any other letter and ++. I've googled the heck out of that.

Putting "++" after a variable means "increment it after its value has been used". Putting "++" before a variable means "increment it before its value is used"

brassbuilder:
pinMode, I am guessing is setting all the Data pins to output?

Yes

brassbuilder:
What is the i in the [] for?

This specifies which element/index of the array is to be used.

brassbuilder:
From my VisualBasic days, I am sure there is a rhyme or reason to all the {} brackets. I know they enclose groupings of the code....

Correct. In VB, there is always a keyword that denotes the end of a sequence of commands, such as "else", "end if", "loop", "next" and so on. In C/C++ the curly brackets do this.

brassbuilder:
Hmmmm....another pin mode....setting A0, A1, and WR to OUTPUT.....but....I thought D0-D6 were defined as OUTPUTS earlier?

Yes they were, but A0, A1 and WR are connected to different Arduino pins to D0..D6, so they also need to be set to OUTPUT.

brassbuilder:
And another bracket...

Ummm... you should buy a book on C/C++. The little O'Reilly "Pocket Reference" books are nice and short if you are already a competent programmer.

brassbuilder:
Start of the loop sequence?

Yes

brassbuilder:
More LETTERS++ and brackets....must have something to do with setting the byte count?

Err...

brassbuilder:
I've googled the heck out of digitalWrite and I still can't get this. It definitely does something with the address bits in this....
Something to do with bytes....and digitalWrite....and bitRead. No clue on this. None.
...
Now it sets WRITE to LOW and HIGH....why? What does this do?
...
When I change that to 200...it goes really fast :slight_smile:
...
And evidently the } bracket is the last brackets enclosing something and something...

All (or at least a heck of a lot) is revealed here:

brassbuilder:
I am concerned of some magic smoke making an appearance.

Little or no danger of that with these components. Tweak the code as much as you like.

brassbuilder:
I am sure these displays have a lot more tricks they could do...

I think we have covered most/all of it.

brassbuilder:
I'm sure you could probably write a book answering my questions.

Yes, but so many better writers than me have already done so.

brassbuilder:
Seeing if I can get a second display hooked up today so it scrolls across two of them....but does that mean I need to change something in the code to get two displays going?

To add more displays, they can share the same D0-D6, A0 & A1 connections to the Arduino. But each WR pin will need a connection to a different Arduino pin.