Go Down

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

brassbuilder

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


PaulRB

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





brassbuilder

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

brassbuilder

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


brassbuilder

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




PaulRB

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.

brassbuilder

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


Go Up