Go Down

Topic: SLR2016 5x7 LED OSRAM Opto Semiconductors and the Arduino code to run them (Read 18811 times) previous topic - next topic

brassbuilder

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

brassbuilder

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

brassbuilder

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

PaulRB

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!

brassbuilder

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


brassbuilder

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



PaulRB

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

brassbuilder

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

PaulRB

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?

PaulRB

Or did you move the delay() function? How many } come after it?

brassbuilder

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);
       }
  }
}



brassbuilder

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.

brassbuilder

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



brassbuilder

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);
       }
}


mixographer

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

Go Up