Arduino Forum

Using Arduino => LEDs and Multiplexing => Topic started by: brassbuilder on Nov 28, 2014, 06:18 am

Title: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Nov 28, 2014, 06:18 am
I hope somebody can help me....at least get me pointed in the right direction.

I have a few SLR2016 5x7 Dot Matrix LED displays to test. I would LOVE to get something set up with an Arduino to just make sure these things work. I have searched the web for days on end and searched through this Arduino forum without luck. I have found a few YouTube videos that show this exact chip with scrolling text, but no one posts the code or schematics on how they did it. What is frustrating is that other users have posted questions on requesting the code or schematics and they do not get a reply.

It is like these people do this just to show off without sharing their knowledge.

These displays have 14 pins. They are:

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

The displays have their own CMOS  memory build in.

I don't have my Arduino kit here (hoping it will be here tomorrow), but I am hoping to get an idea where to go with this.

I see on the board that on one side of the board is marked Digital 0 through 13. Will I just jumper each of my D0 through D6 to these?

I see an A0 and A1 on the board too....will my A0 and A1 go to those?

Ground and 5v is pretty self explanatory.

That Display Blank and Clear do not have any corresponding connectors.

I found one comment on a website that said "I realized that they used the standard ASCII charset, so they are extremely easy to drive."

Ummm....no. They aren't when you have no idea what you are doing.

I have the Arduino software installed. I have the ASCII charset codes. I understand how to load code onto the Arduino.

Can anyone get me pointed in the right direction?

Thanks so much.

Mike


 
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: PaulRB on Nov 28, 2014, 11:05 am
Hi Mike and welcome.

I see on the board that on one side of the board is marked Digital 0 through 13. Will I just jumper each of my D0 through D6 to these?
Yes, but don't use D0 or D1. They are used for uploading your sketch on most Arduinos.

I see an A0 and A1 on the board too....will my A0 and A1 go to those?
They can do, although that isn't what they are primarily intended for. The "A" pins are analog inputs which can measure the input voltage level connected to them, as opposed to the "D" pins which are digital input/outputs and can only distinguish a low or high level. So most users tend to use analog inputs for potentiometers, temperature/light sensors and so on. But they are multi-purpose and can be used as digital outputs too. It would be more "normal" to connect the A0 & A1 to 2 more digital outputs on the Arduino.

That Display Blank and Clear do not have any corresponding connectors.
Connect those to 5V. That will prevent them doing anything. Don't leave them "floating" (unconnected).

The other connection that needs to go to a digital output on the Ardunino is the "WR".

Let us know when you have it all connected up and what outputs you have used. Can help you write the script.

Paul
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Nov 28, 2014, 04:28 pm
Thanks Paul. That cleared up some of my questions. That is easy enough to understand and was a huge help.

Could you (or anybody) get me pointed in the right direction on writing the code? I'd post what I have but I have nothing and none of the tutorials have been any help. Everything I have found for LED has to do with getting an LED to light up instead of getting text to an LED 5x7 4-digit matrix display. Hooking up an LED and controlling it with a switch....THAT I could do :)

I know at the minimum, I need:

void setup()

void loop()

In the "void setup()" do I need to define or declare my pins? I think the "void loop()" is where i will run the code that will actually scroll the text.

From looking at the ASCII character set, if I want a capital letter "A", it gets set up like this:

D0 1
D1 0
D2 0
D3 0
D4 0
D5 0
D6 1

I know that "0" is LOW and "1" is HIGH.

I am guessing this will be good to know at some point...

The sheet I am using also has a column called HEX. If I follow that out, the capital "A" has either 14 assigned or 41 depending if I read Horizontal/Vertical or Vertical/Horizontal.

Thanks

Mike
 
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: PaulRB on Nov 28, 2014, 06:33 pm
Mike, don't worry about the binary or hex codes for letters. They are ASCII codes, so in your sketch you will just be able to put 'A' and an A will appear!

Here's a starter, untested. You will need to adjust for the exact pins you end up using.

Code: [Select]


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

#define SLR2016_A0 9
#define SLR2016_A1 10
#define SLR2016_WR 11

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 (char c = 'A'; c <= 'Z'; c++) {

    digitalWrite(SLR2016_A0, LOW);
    digitalWrite(SLR2016_A1, LOW);

    for (byte i = 0; i < 7; i++) {
      digitalWrite(SLR2016_D[i], bitRead(c, i));
    }

    digitalWrite(SLR2016_WR, LOW);
    digitalWrite(SLR2016_WR, HIGH);

    delay(500);
  }
}

Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Nov 28, 2014, 06:42 pm
I even understand all of that :)

What about the loop sequence?

Thanks so much!!

Mike
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: PaulRB on Nov 28, 2014, 06:46 pm
What about the loop sequence?
Err.. What about it?
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Nov 28, 2014, 06:56 pm
Don't I use the loop sequence to send the text to the display?

Is there any special code that I need to post for that? Or do I just write out what I want to show up before the "void loop().

And to take it a step further, will that scroll the text too?

Mike
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: PaulRB on Nov 28, 2014, 09:21 pm
Yes, setup() gets called once only, when the Arduino is powered up or reset. Then loop() gets called over and over. The loop() code I gave before is just a very simple example just to allow you to test if you have wired up the display correctly and it is working (hopefully I got it right - it is my guesswork having skimmed the data sheet very briefly indeed!).

All my loop() code does, or at least is intended to do, is display the letters A to Z in sequence on the display's first position. No scrolling messages yet - one step at a time!
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Nov 28, 2014, 10:15 pm
I got it....I didn't see that the code you posted had a scroll bar on the right. I see the loop code now too. I just saw the setup code and thought that was it.

Everything makes sense now. Mail hasn't come but hoping that Arduino kit shows up today.

Mike
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Nov 29, 2014, 12:06 am
Got my kit in today!

Got the Arduino hooked up to the computer and drivers loaded. I loaded the code listed above and got these errors:

sketch_nov28a.ino: In function 'void setup()':
sketch_nov28a:9: error: expected initializer before '<' token
sketch_nov28a:13: error: could not convert 'pinMode(9u, 1u)' to 'bool'
sketch_nov28a:14: error: expected `)' before ';' token
sketch_nov28a.ino: In function 'void loop()':
sketch_nov28a:21: error: expected initializer before '<=' token
sketch_nov28a:35: error: expected primary-expression at end of input
sketch_nov28a:35: error: expected `;' at end of input
sketch_nov28a:35: error: expected primary-expression at end of input
sketch_nov28a:35: error: expected `)' at end of input
sketch_nov28a:35: error: expected statement at end of input
sketch_nov28a:35: error: expected `}' at end of input


I'm attempting to figure this out.....but any help is def appreciated :)

Mike
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Nov 29, 2014, 12:18 am
Just to add....

I went through the Tools and made sure the Arduino Uno was selected.
Made sure the correct COM port (4) was selected
I ran the code through the compiler too

Mike
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: PaulRB on Nov 29, 2014, 12:24 am
Apologies Mike, I made a couple of mistakes. I have edited the code in my earlier post -try it again please.
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Nov 29, 2014, 12:28 am
Hold on....I forgot to define all my pins in the code.

Mike
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: PaulRB on Nov 29, 2014, 12:34 am
Oops just made another change... not easy doing this on smartphone!
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Nov 29, 2014, 12:46 am
IT WORKED!!! Well....it compiled anyway.... :)

Before I load it, could take a look at this and my questions at the end...


I changed this to correspond to my pins:

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
#define SLR2016_D0 5
#define SLR2016_D1 6
#define SLR2016_D2 7
#define SLR2016_D3 8
#define SLR2016_D4 9
#define SLR2016_D5 10
#define SLR2016_D6 11

QUESTIONS:

Do I need to define the GND, 5V, Blank, and Clear pins?

From the OSRAM display, I have the following pins going to the 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)

Thanks

Mike
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Nov 29, 2014, 12:57 am
And....it appears I need to add all my pins to the pinMode, right?
Mike
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: PaulRB on Nov 29, 2014, 09:28 am
The SLR2016_D[] is an array that should hold the pin numbers of only the data pins for the display, not the other pins too. You dont need #defines for those data pins as well.

In other words, my example code above just needed you to adjust the pin numbers, not add any more #defines or elements to the array.

You dont need to #define the other pins (after all, what would you define them as?)

Hope that anwers your questions. Your choice of Arduino pins should be fine.

So does it work?
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: PaulRB on Nov 29, 2014, 10:03 am
And....it appears I need to add all my pins to the pinMode, right?
No, it should be all there.
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Nov 29, 2014, 02:15 pm
The SLR2016_D[] is an array that should hold the pin numbers of only the data pins for the display, not the other pins too. You dont need #defines for those data pins as well.

In other words, my example code above just needed you to adjust the pin numbers, not add any more #defines or elements to the array.

You dont need to #define the other pins (after all, what would you define them as?)

Hope that anwers your questions. Your choice of Arduino pins should be fine.

So does it work?
Yes....that did answer my questions :)

It works....sort of. I reread your intent with the code and it appears it is to cycle through the alphabet starting with A in the first position.

It cycles through x, y, z and {. It starts at Digit 0 (far right digit), then goes to Digit 2 (second from left), then Digit 1 (second from right) and then finally Digit 3 (far left). The exception is the bracket. It only does Digit 0 and Digit 2 and then the process repeats itself.

And is this code specific to Arduino or is it C++ or something?

Thanks!

Mike
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Nov 29, 2014, 02:50 pm
BTW....the brackets I'm getting are 2 { brackets and not a set of {} brackets.
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: PaulRB on Nov 29, 2014, 02:51 pm
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.
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Nov 29, 2014, 03:29 pm
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

Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Nov 29, 2014, 03:56 pm
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

Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Nov 29, 2014, 04:23 pm
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
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: PaulRB on Nov 29, 2014, 07:00 pm
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?
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Nov 29, 2014, 07:11 pm
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
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Nov 29, 2014, 07:31 pm
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
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: PaulRB on Nov 29, 2014, 08:07 pm
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?
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Nov 29, 2014, 08:35 pm
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 :)

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

Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: PaulRB on Nov 30, 2014, 01:02 am
Ok Mike. Won't have much time to help you tomorrow (I have house guests). So Monday.

Paul
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Nov 30, 2014, 01:05 am
Sounds good. Thanks for letting me know.
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: PaulRB on Nov 30, 2014, 10:59 am
Well, my house guests got delayed...

Code: [Select]

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);
  }
}
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Nov 30, 2014, 05:40 pm
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
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Nov 30, 2014, 05:43 pm
I fixed it! I fixed it!

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

It works!!!

Mike
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Nov 30, 2014, 05:55 pm
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
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Nov 30, 2014, 06:42 pm
Can we go through this code pretty much line by line and explain what it does? I think I understand parts of it.


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.


#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?


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.


void setup() {
Start of the setup routine?


for (byte i = 0; i < 7; i++) {
    pinMode(SLR2016_D, OUTPUT);
  }
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....


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...


void loop() {
Start of the loop sequence?


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?


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....
   

for (byte i = 0; i < 7; i++) {
       digitalWrite(SLR2016_D, bitRead(msg[p-c], i));
     }
Something to do with bytes....and digitalWrite....and bitRead. No clue on this. None.
     

digitalWrite(SLR2016_WR, LOW);
     digitalWrite(SLR2016_WR, HIGH);
   }
Now it sets WRITE to LOW and HIGH....why? What does this do?


delay(500);
 }
}
When I change that to 200...it goes really fast :)

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


Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Nov 30, 2014, 08:28 pm
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

 
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: PaulRB on Dec 01, 2014, 12:22 am
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.
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: PaulRB on Dec 01, 2014, 01:02 am
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.

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.


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.

Start of the setup routine?
Errr... yes.

I am guessing this is setting the bytes to 7.
Don't understand...

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"

pinMode, I am guessing is setting all the Data pins to output?  
Yes
What is the i in the [] for?  
This specifies which element/index of the array is to be used.

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.

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.

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.

Start of the loop sequence?
Yes

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

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 :)
...
And evidently the } bracket is the last brackets enclosing something and something...
All (or at least a heck of a lot) is revealed here:
http://arduino.cc/en/Reference/HomePage (http://arduino.cc/en/Reference/HomePage)
 
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.

I am sure these displays have a lot more tricks they could do...
I think we have covered most/all of it.

I'm sure you could probably write a book answering my questions.
Yes, but so many better writers than me have already done so.

Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: PaulRB on Dec 01, 2014, 01:19 am
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.
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Dec 01, 2014, 01:25 am
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.
OK. I almost had it. I was sharing the WR pin too.

And then add that pin to the #define?

Mike
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Dec 01, 2014, 01:29 am
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.

Actually bought two today specifically for programming Arduinos.

Beginning Arduino Programming (Technology in Action)

Beginning C for Arduino: Learn C Programming for the Arduino (Technology in Action)

for (byte i = 0; i < 7; i++) {
       digitalWrite(SLR2016_D, bitRead(msg[p-c], i));
^^^^That line....what does it do? I don't have a clue on what it does. Can't even make an educated guess after the last couple of days.

I have a happily scrolling SLR2016 today :)

Thanks so much for the help! I would have never figured this out on my own. I learned a lot the last couple of days. This would have taken me weeks to get.

Mike
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: PaulRB on Dec 01, 2014, 08:37 am
Quote
And then add that pin to the #define?
Yes. You could call it SLR2016_WR2. The for(byte c...) loop would need to go from 0 to 7 so the sketch writes to all 8 positions. When c <= 4 you would use SLR2016_WR and when c > 4 use SLR2016_WR2. There will be other adjustments to make, I'll leave you to figure those out.

Quote
^^^^That line....what does it do?
Did you read up on the functions used on the link I gave above yet? In short, it picks out the character from the message corresponding to the  character position on the display. It breaks that character's ascii code down into 7 bits and writes each one to one if the data lines.
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Dec 01, 2014, 05:37 pm
You have a lot of confidence in me :) But I'm stuck....and I have read up on the functions link....multiple times. :) And Googled.

I'm having problems adding:

When c <= 4 you would use SLR2016_WR and when c > 4 use SLR2016_WR2.

Do I need an "if" or an "if....else" statement?

Here is what I have:



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

#define SLR2016_A0 4
#define SLR2016_A1 3
#define SLR2016_WR 2
#define SLR2016_WR2 12   <<<<<<<<<<<<<<<   Added that line

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

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);
  pinMode(SLR2016_WR2, OUTPUT);      <<<<<<<<<<<<<<    Added that line

}

void loop() {

  for (byte p = 3; p <= 27; p++) {
 
    for (byte c = 7; c < 4; c++) {             

the 7 used to be a 0, changing c < 4 to c < = 4 is easy enough but to use SLR2016_WR and then use SLR2016_WR2 if c > 4 is where I am lost. I'm not getting the syntax of it. I've tried a few things...my guess is an "if" or "if...else" statement. Its been 10 years or more since my VisualBasic days...
   
      digitalWrite(SLR2016_A0, bitRead(c, 0));
      digitalWrite(SLR2016_A1, bitRead(c, 1));
 
      for (byte i = 0; i < 7; i++) {
        digitalWrite(SLR2016_D, bitRead(msg[p-c], i));
      }
     
      digitalWrite(SLR2016_WR, LOW);
      digitalWrite(SLR2016_WR, HIGH);
    }
   
    delay(300);
  }
}



I'm still working it. I kind of know what needs to be done....I just don't know the syntax of it.
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: PaulRB on Dec 01, 2014, 07:43 pm
Mike,

In VB you would write

Code: [Select]

for c = 0 to 7
  ...
next


In C the equivalent is

Code: [Select]

for (byte c = 0; c <= 7; c++) {
  ...
}


Your attempt above would have started c at 7 instead of 0 and increased it until it was less than 4. In other words done nothing!

For the second WR connection you would need something like
Code: [Select]

if (c < 4) {    
  digitalWrite(SLR2016_WR, LOW);
  digitalWrite(SLR2016_WR, HIGH);
else {
  digitalWrite(SLR2016_WR2, LOW);
  digitalWrite(SLR2016_WR2, HIGH);
}

Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Dec 01, 2014, 08:22 pm
OK....so I was on the right path as far as the if....else statement.

I didn't think that 7 was in the right spot. After explaining it, it makes sense.

I'm not sure where to drop this code:

Code: [Select]

if (c < 4) {    
  digitalWrite(SLR2016_WR, LOW);
  digitalWrite(SLR2016_WR, HIGH);
else {
  digitalWrite(SLR2016_WR2, LOW);
  digitalWrite(SLR2016_WR2, HIGH);
}



I know it goes into the loop....

Code: [Select]

void loop() {

  for (byte p = 3; p <= 27; p++) {
 
    for (byte c = 0; c < 7; 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(300);
  }
}


My guess it has to replace at least this:

Code: [Select]

digitalWrite(SLR2016_WR, LOW);
digitalWrite(SLR2016_WR, HIGH);
    }


But if I replace just that, it does not compile. I tried replacing different sections without success....

I'm trying....I'd like to get two displays running before I quit bugging you :)

Thanks for all the assistance. It's been a learning process.

Mike
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Dec 01, 2014, 08:40 pm
This code compiles:
Code: [Select]

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

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

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);
  pinMode(SLR2016_WR2, OUTPUT);

}

void loop() {

  for (byte p = 3; p <= 27; p++) {
  
    for (byte c = 0; c < 7; 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));
      }
      
      if (c < 4) {    
  digitalWrite(SLR2016_WR, LOW);
  digitalWrite(SLR2016_WR, HIGH); }
else {
  digitalWrite(SLR2016_WR2, LOW);
  digitalWrite(SLR2016_WR2, HIGH);
}
  
    
    delay(300);
       }
  }
}



But....it sends Mary had a little lamb to the first display and the second display has random characters and only Digits 0, 1, 2, are changing. Display 3 is static......I'm missing something....something simple I'm sure.....

I think it has something to do with those bytes....

Mike
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Dec 01, 2014, 09:09 pm
Arrrrgh....I am sooooo close! I checked all my wiring and I found one jumper wire off one row.

I have "Mary has a little lamb" scrolling on both screens but independently of each other. Display one scrolls "Mary had a little lamb" and display two scrolls "Mary had a little lamb" but they are not in sync...and there are a few random characters....

I'm using the code that I last posted.

But...I also tried doing an else if statement

Code: [Select]

if (c <= 4) {    
  digitalWrite(SLR2016_WR, LOW);
  digitalWrite(SLR2016_WR, HIGH); }
else if (c > 4)
  digitalWrite(SLR2016_WR2, LOW);
  digitalWrite(SLR2016_WR2, HIGH);
}


With no luck....
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: PaulRB on Dec 01, 2014, 11:00 pm
Mike, add 4 more spaces before Mary and 4 more spaces after lamb. Change the p loop to start at 7 and finish at 35.

What do you mean by "independantly of each other"? Isn't the idea that letters scroll off the left of one display and appear on the right of the other?

Your "else if" does nothing: if c is not less than 4 it must be greater or equal to 4!
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Dec 01, 2014, 11:34 pm
Mike, add 4 more spaces before Mary and 4 more spaces after lamb. Change the p loop to start at 7 and finish at 35.
I added the spaces and changed the p loop. That took care of random characters.

Isn't the idea that letters scroll off the left of one display and appear on the right of the other?

Your "else if" does nothing: if c is not less than 4 it must be greater or equal to 4!
That would be the idea the way I want it....what I mean is that the left display has "Mary has a little lamb" and the right display has "Mary has a little lamb" each scrolling the phrase. The phrase is not scrolling from the right display to the left display (or left to right for that matter) as one phrase. I have two independent scrolling phrases....its like I have two separate displays doing their own thing instead of working together.

Mike

Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Dec 01, 2014, 11:47 pm
Would it have something to do with the way I have the board wired? I have all this mounted on a breadboard.

Just as an example, for pin 5 (D0) on the SLR2016, I have a jumper going from the same breadboard row the SLR2016 pin is on from the left display to pin 5 on the Arduino and then I have another jumper going from pin 5 on the second display going to the same pin 5 breadboard row of the first display.

This might be easier....I jumpered from the second display to the same pin on the first display except for the WR which got the #12 terminal on the Arduino.

From looking at any schematics with two displays hooked in series, this appears the way they have it.

Mike


Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: PaulRB on Dec 02, 2014, 12:12 am
I'm struggling to visualise what you are seeing. Can you post a short video on youtube? Alternatively change the delay to 5000 and describe step by step what you see happening. What characters appear in what position in which display...
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Dec 02, 2014, 12:37 am
I'm struggling to visualise what you are seeing. Can you post a short video on youtube? Alternatively change the delay to 5000 and describe step by step what you see happening. What characters appear in what position in which display...
Here you go. It is pretty self explanatory. I left the camera on long enough to get a pretty good scroll. It is a little dark but if I turned the desk lamp light on, the letters faded out because of the light.

And I just noticed that Digit 3 on the right display wasn't working. I replaced that display and the same thing. I only have Digits 0, 1, and 2 working on that one.

https://www.youtube.com/watch?v=gNS5aCML1XU&feature=youtu.be

Mike
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: PaulRB on Dec 02, 2014, 01:04 am
Ok.

Change WR and WR2 around so that

Code: [Select]


#define SLR2016_WR 12
#define SLR2016_WR2 2



Then fix this for loop to get that unused character working

Code: [Select]


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



What I don't understand is why the characters don't all update together. Did you put any extra delays in?
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: PaulRB on Dec 02, 2014, 01:07 am
Or did you move the delay() function? How many } come after it?
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Dec 02, 2014, 01:20 am
I just pulled this code off of Sketch. This is the code that is running right now. Three } are at the end. I think I had to add one to get the code to compile.....did I put it in the wrong place?

I made the changes. Moved WR to pin 12 and WR2 to pin 2. I added the = sign in the one line.

All the characters are now working. I still have that funky scroll like in the YouTube video.

Code: [Select]

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

#define SLR2016_A0 4
#define SLR2016_A1 3
#define SLR2016_WR 12
#define SLR2016_WR2 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);
  pinMode(SLR2016_WR2, OUTPUT);

}

void loop() {

  for (byte p = 7; p <= 35; p++) {
 
    for (byte c = 0; c <= 7; 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));
      }
     
      if (c < 4) {   
  digitalWrite(SLR2016_WR, LOW);
  digitalWrite(SLR2016_WR, HIGH); }
else {
  digitalWrite(SLR2016_WR2, LOW);
  digitalWrite(SLR2016_WR2, HIGH);
}
 
   
    delay(300);
       }
  }
}


Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Dec 02, 2014, 02:00 am
I just moved one of those } after the delay() and moved it to before delay() and it instantly made the display scroll faster but I still have that independent scroll.
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Dec 02, 2014, 05:45 am
I GOT IT!!!! IT'S WORKING!!!

I hope you can tell I am excited by all the caps and exclamation points.

I changed this line of code from this:

Code: [Select]

if (c < 4) {


to this:

Code: [Select]

if (c >= 4) {  


I wasn't even going to look at it before I went to bed, but I couldn't resist. After looking at the code for the 1000th time, I just had a feeling that the (c < 4) was the problem child. I tried (c > 4) but that just hosed up the displays. Then I tried (c =>4) but that wouldn't compile. Then I tried (c >= 4) and that worked. It is scrolling from the right to the left across all 8 digits.

I got lucky is all I can say. It wasn't because I knew what I was doing. LOL.

Thanks so much for all the help. I would have never figured this out on my own. I spent a lot of time researching the code you was writing and modifying a lot of it too. I had way more failures (I know what doesn't work) than successes, but I had a lot of fun figuring this out.

Now I'm going to hook up three display :) But I'm going to see if I can figure this out on my own.

Mike


Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Dec 02, 2014, 05:56 am
For anyone following along, here is the final version of the code to run two of these displays with some comments added so I don't forget what needs to change.

Code: [Select]

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

#define SLR2016_A0 4
#define SLR2016_A1 3
#define SLR2016_WR 12
#define SLR2016_WR2 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);
  pinMode(SLR2016_WR2, OUTPUT);

}

void loop() {

  for (byte p = 7; p <= 35; p++) {  
    
    /*the above code may need to be changed depending on the
    words you want scrolled. I've left 7 spaces in front and
    behind the scroll. I change the 35 to one less digit than
    the total digits between the quotation marks. Otherwise,
    random characters have a tendency of showing up on the
    display */
  
    for (byte c = 0; c <= 7; 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));
      }
      
      if (c >= 4) {    
  digitalWrite(SLR2016_WR, LOW);
  digitalWrite(SLR2016_WR, HIGH); }
else {
  digitalWrite(SLR2016_WR2, LOW);
  digitalWrite(SLR2016_WR2, HIGH);
}
    }
  
    delay(200);
       }
}

Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: mixographer on Dec 06, 2014, 09:23 am
Karma to PaulRB for all the great info in this thread. 

brassbuilder, the most common type of displays that work like these are HP DL2416 displays. If you wanted to look at other examples and sketches I imagine you would find a lot by googling 'arduino DL2416.' Other popular displays were DL1414 and DL1416. They are all parallel input displays like yours. You would have to modify the examples, but it might be fun and you would learn a lot. 

Jimmy
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: PaulRB on Dec 06, 2014, 10:54 am
How's that third display coming along Mike?
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Dec 08, 2014, 12:21 am
How's that third display coming along Mike?
It's not :(

I'm at a Microsoft Desktop Support Technician course for the next two weeks. I'm going to probably be tied up with that until almost Christmas.

And I kind of got sidetracked from the 3 displays. Now, I'm trying to figure out the code to just display a static message that doesn't scroll.

I'm slowly trying to go through the two books that I have too.

Mike
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Dec 08, 2014, 01:54 pm
Karma to PaulRB for all the great info in this thread.

brassbuilder, the most common type of displays that work like these are HP DL2416 displays. If you wanted to look at other examples and sketches I imagine you would find a lot by googling 'arduino DL2416.' Other popular displays were DL1414 and DL1416. They are all parallel input displays like yours. You would have to modify the examples, but it might be fun and you would learn a lot.

Jimmy

And thanks for this information! I googled it and it appears that there is a lot more info out there on the DL series than the SLRs that I am playing with.

Mike
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Dec 09, 2014, 01:42 pm
I have a curious little problem....

I set up another board because I did not want to take my working 2 display unit apart. That one is run on a UNO. I am now using a MEGA 2560.

When I load the code for the single scroll display....it scrolls, but it is random characters. I've taken this apart and rewired it (carefully) 3 times now.

If I load the code for the single digit to scroll A-Z, it scrolls from P-Z and tosses a few random characters in before it starts over at P.

I've made the setup changes in Sketch as far as telling it what board and COM port I'm using.

Am I missing anything else?

Mike
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: PaulRB on Dec 09, 2014, 01:58 pm
Post your list of pin connections and the updated sketch please Mike.

Given that P to Z show correctly, I would guess D0 to D3 are connected OK but one or more of D4, D5 or D6 are the problem. Either your wiring is still wrong/faulty or maybe you have used an unsuitable output on the mega.

Have a look at the table on page 6 of the data sheet:

http://media.digikey.com/pdf/Data%20Sheets/Osram%20PDFs/SLx2016.pdf (http://media.digikey.com/pdf/Data%20Sheets/Osram%20PDFs/SLx2016.pdf)

Do you see the "random characters" there? Which row on the table?
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Dec 09, 2014, 07:39 pm
Well that is interesting...

My "random characters" is the whole row 6 starting with "P" and ending with "_".

Is there a way to check the output ports on the Arduino?

I've wired this three times, I've moved the display to different areas of the breadboard, and I've used different jumper wires.

Mike
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: PaulRB on Dec 09, 2014, 08:05 pm
Post your list of pin connections and the updated sketch please Mike.
Also try swapping the display with one from the other circuit (you know those work).

To test an Arduino output, just load up the blink sketch, set it to the pin to be tested, and stick an led (+series resistor) on that output.
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Dec 10, 2014, 04:02 am
Also try swapping the display with one from the other circuit (you know those work).

To test an Arduino output, just load up the blink sketch, set it to the pin to be tested, and stick an led (+series resistor) on that output.
Electronics 101

The jumper wire on pin 9 was not working....it didn't make the LED blink. I checked continuity through the jumper and....nothing. Replaced the jumper (checked continuity first) and checked continuity on the jumpers for pins 10 and 11 and everything is working perfectly again.

I knew it was going to be something simple I didn't think of....gotta remember to check those jumper wires from now on....

That blink program was kind of a fun little diversion :)

Now back to the static display.

Care to give me any hints on this Paul? :) I can't quite figure out how much of the code I can delete....

Mike


Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: PaulRB on Dec 10, 2014, 07:30 am
Well, if I remember, its the "for (byte p" loop that does the scrolling, so just take that out, and all references to "p". Limit your message to what will fit on the display (no leading/trailing spaces).
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Dec 10, 2014, 01:28 pm
Well, if I remember, its the "for (byte p" loop that does the scrolling, so just take that out, and all references to "p". Limit your message to what will fit on the display (no leading/trailing spaces).
That was easy. Took a couple of tries, but I got my message displayed. But it is in reverse....

Mike is ekiM

I suspect it is something to do with the ++ in the code....and since you had mentioned on page 3 of this post that the ++ was an increment variable, I tried moving the ++ on either side of the letters...that didn't do anything.....or maybe it has to do with one of the < signs.

I also tried replacing all the ++ with --.

ekiM :)

Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: PaulRB on Dec 10, 2014, 01:53 pm
Odd, the scrolling message was not reversed. Post the sketch, I'll take a look.
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Dec 10, 2014, 02:05 pm
Odd, the scrolling message was not reversed. Post the sketch, I'll take a look.
Code: [Select]

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

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

char msg[] = "Mike";

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 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[c], i));
      }
      
      digitalWrite(SLR2016_WR, LOW);
      digitalWrite(SLR2016_WR, HIGH);
    }
    
    delay(500);
  }
}


I left the delay in there, but I'm pretty sure it no longer serves a purpose.

Mike
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: PaulRB on Dec 10, 2014, 03:48 pm
Ok, I see it. In the scrolling text sketch there was this line:
Code: [Select]

  digitalWrite(SLR2016_D[i], bitRead(msg[p-c], i));


When you removed the reference to "p", you removed the "-" also. An easy mistake, but the fact that c was subtracted from p was what was preventing the scrolling message from getting reversed.

so to fix it...
Code: [Select]

  digitalWrite(SLR2016_D[i], bitRead(msg[3-c], i));


The reason it gets reversed is that, as we found out with that very first A-Z test sketch, that position zero is on the far right (like a purely numeric display), not on the left (as you might expect with a text display).
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Dec 10, 2014, 06:21 pm
Ok, I see it. In the scrolling text sketch there was this line:
Code: [Select]

  digitalWrite(SLR2016_D[i], bitRead(msg[p-c], i));


When you removed the reference to "p", you removed the "-" also. An easy mistake, but the fact that c was subtracted from p was what was preventing the scrolling message from getting reversed.

so to fix it...
Code: [Select]

  digitalWrite(SLR2016_D[i], bitRead(msg[3-c], i));


The reason it gets reversed is that, as we found out with that very first A-Z test sketch, that position zero is on the far right (like a purely numeric display), not on the left (as you might expect with a text display).
And that fixed it :)

Now....and I'm going to try to figure this out myself with all the code that I've received....I'm going to set up a second static display and I'm going to try for that third scrolling display....

I'll post back whether I succeed.

Been quite fun :)

Mike
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Dec 11, 2014, 12:21 pm
OK Paul....
I took a shot at that third display and I'm not quite there. Here is what I can tell you:

1. From the left display to the right display, my Write pins are numbered WR1, WR2, WR3

2. Displays 1 and 2 (the left and center display) is scrolling the phrase "Mary had a little lamb" just fine.

3. Display 3 is scrolling "Mary had a little lamb" on its own independent of the other two.

4. I am 99% sure my setup is correct.

5. I am 99% sure my problem is in the loop and it has something to do with that if...else statement. I tried to just add another else statement, but without a corresponding if statement, it will not compile. The code posted below compiles, but the phrase does not scroll from the farthest right display to the farthest left display. It's scrolling from the center display to the left display...and the right display is scrolling on its own. :(

Care to point out where I went wrong?

Mike

Here are my pinouts:

1   WR1   4
     WR2   3
     WR3   2
2   A1     5
3   A0     6
4   vCC   5v
5   D0     7
6   D1     8
7   D2     9
8   D3     10
9   D4     11
10  D5     12
11  D6    13
12  BL     5v
13  CL     5V
14  GND   GND

 
And here is the code:

Code: [Select]

const byte SLR2016_D[] = {7, 8, 9, 10, 11, 12, 13};

#define SLR2016_A0 6
#define SLR2016_A1 5
#define SLR2016_WR1 4
#define SLR2016_WR2 3
#define SLR2016_WR3 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_WR1, OUTPUT);
  pinMode(SLR2016_WR2, OUTPUT);
  pinMode(SLR2016_WR3, OUTPUT);

}

void loop() {

  for (byte p = 7; p <= 35; p++) {  
    
    /*the above code may need to be changed depending on the
    words you want scrolled. I've left 7 spaces in front and
    behind the scroll. I change the second number to one less digit than
    the total digits between the quotation marks. Otherwise,
    random characters have a tendency of showing up on the
    display */
  
    for (byte c = 0; c <= 7; 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));
      }
      
      if (c >= 4) {    
  digitalWrite(SLR2016_WR1, LOW);
  digitalWrite(SLR2016_WR1, HIGH); }
else {
  digitalWrite(SLR2016_WR2, LOW);
  digitalWrite(SLR2016_WR2, HIGH);
  digitalWrite(SLR2016_WR3, LOW);
  digitalWrite(SLR2016_WR3, HIGH);
}
    }
  
    delay(300);
       }
}

Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Dec 11, 2014, 01:23 pm
After looking at this and reading my books, I am guessing that the else statement needs to be changed to an if statement and another else statement added for WR3.

But I'm not sure....

Mike

Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: PaulRB on Dec 11, 2014, 02:33 pm
You need to add more spaces before Mary and after lamb, to avoid seeing those random characters like last time. These random characters come from bytes of ram memory either side of your message string, which may be unused, or may contain your other program variables. With languages like BASIC, you get an error message if to try to access an index or an array that is "out of bounds", but C does not check that kind of thing for you. You are expected, as a C programmer, to do any neccessary checking yourself.

Your display is now 12 characters long, not 8, so you need to update the "for (byte c...)" loop.

For your WR pins, try this:

Code: [Select]

      if (c >= 8) {    
        digitalWrite(SLR2016_WR1, LOW);
        digitalWrite(SLR2016_WR1, HIGH); }
      else if (c >= 4) {    
        digitalWrite(SLR2016_WR2, LOW);
        digitalWrite(SLR2016_WR2, HIGH); }
      else {
        digitalWrite(SLR2016_WR3, LOW);
        digitalWrite(SLR2016_WR3, HIGH);
      }




Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Dec 11, 2014, 06:17 pm
It works :)

You have no idea how close I got to getting this. One of my tries had code very close to this. I had the right idea, but the wrong syntax.

Now....I am going to try to convert them to 3 static displays....

I'll give it my best shot before I ask for any advice. After doing the single display, I kind of have an idea of what to do.

Mike
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Dec 11, 2014, 06:37 pm
For anyone following along and because I detest when a problem gets figured out on a forum and someone posts "I got it figured out! Thanks!" and then does not provide the "figured out" part.....it drives me up the wall....

This code will run on three displays:

Code: [Select]

const byte SLR2016_D[] = {7, 8, 9, 10, 11, 12, 13};

#define SLR2016_A0 6
#define SLR2016_A1 5
#define SLR2016_WR1 4
#define SLR2016_WR2 3
#define SLR2016_WR3 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_WR1, OUTPUT);
  pinMode(SLR2016_WR2, OUTPUT);
  pinMode(SLR2016_WR3, OUTPUT);

}

void loop() {

  for (byte p = 7; p <= 35; p++) {  
    
    /*the above code may need to be changed depending on the
    words you want scrolled. I've left 7 spaces in front and
    behind the scroll. I change the second number to one less digit than
    the total digits between the quotation marks. Otherwise,
    random characters have a tendency of showing up on the
    display */
  
    for (byte c = 0; c <= 11; 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));
      }
      
      if (c >= 8) {    
        digitalWrite(SLR2016_WR1, LOW);
        digitalWrite(SLR2016_WR1, HIGH); }
      else if (c >= 4) {    
        digitalWrite(SLR2016_WR2, LOW);
        digitalWrite(SLR2016_WR2, HIGH); }
      else {
        digitalWrite(SLR2016_WR3, LOW);
        digitalWrite(SLR2016_WR3, HIGH);
      }

    }
  
    delay(300);
       }
}

Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Dec 11, 2014, 06:41 pm
Paul,
I got the static part figured out. That was pretty easy....but I am getting random characters at the end of the displays....and the "random characters" looks like it is row 1 starting with the 8th thru the 11th character. I know how to fix that in the scroll code....but I'm at a lost for the static code.

Here is the code:

Code: [Select]


const byte SLR2016_D[] = {7, 8, 9, 10, 11, 12, 13};

#define SLR2016_A0 6
#define SLR2016_A1 5
#define SLR2016_WR1 4
#define SLR2016_WR2 3
#define SLR2016_WR3 2

char msg[] = "Michael";

void setup() {

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

  pinMode(SLR2016_A0, OUTPUT);
  pinMode(SLR2016_A1, OUTPUT);
  pinMode(SLR2016_WR1, OUTPUT);
  pinMode(SLR2016_WR2, OUTPUT);
  pinMode(SLR2016_WR3, OUTPUT);

}

void loop() {

  {
    for (byte c = 0; c <= 11; 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[11-c], i));
      }
     
      if (c >= 8) {   
        digitalWrite(SLR2016_WR1, LOW);
        digitalWrite(SLR2016_WR1, HIGH); }
      else if (c >= 4) {   
        digitalWrite(SLR2016_WR2, LOW);
        digitalWrite(SLR2016_WR2, HIGH); }
      else {
        digitalWrite(SLR2016_WR3, LOW);
        digitalWrite(SLR2016_WR3, HIGH);
      }

    }
 
    delay(300);
       }
}



Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: PaulRB on Dec 11, 2014, 11:05 pm
Same problem again Mike!

Your display is 12 characters long but your message is only 7 long. When the sketch acceses indexes 7 to 11 of the message to send them to the display, it is accessing memory bytes that are either unused and contain random data, or are other variables from your sketch. Just pad your message out to 12 with spaces.
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: brassbuilder on Dec 12, 2014, 01:08 am
Well that was easy :)

I have to say you helped me exceed my goals when I first started this project. I think initially it was to get a display of scrolling text. I got that and more and learned a lot in the process.

I think I'm going to try a simpler project next.

Thanks :)

Mike
Title: Re: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them
Post by: PaulRB on Dec 12, 2014, 09:46 am
You're welcome Mike.