24x6 matrix problem.

Hello guys, i have made a 24x6 matrix, which shows the message “TEMP IS: (variable)” where variable is taken from sensor. The problem is this - around the digits there are lucent diods (here is a picture - http://postimg.org/image/qk3f78y7l/)
The code is in pdf.

arduino.pdf (19.7 KB)

Hello guys, i have made a 24x6 matrix, which shows the message “TEMP IS: (variable)” where variable is taken from sensor. The problem is this - around the digits there are lucent diods (here is a picture - http://postimg.org/image/qk3f78y7l/).
Can anyone help me with this problem.

arduino.pdf (19.7 KB)

Why would you wrap a text file in a pdf? If you expect people to open your file, you will post it AS A TEXT FILE.

:slight_smile:

Code.txt (6.5 KB)

Why on earth did you post the code as a PDF? If you want any help, cut and paste your code as text between code tags as described in how to post code properly

Pete

#define BT {B11111000,B00100000,B00100000,B00100000,B00100000,B00100000}
#define BU {B10001000,B10001000,B10001000,B10001000,B10001000,B01110000}
#define BM {B10001000,B11011000,B10101000,B10101000,B10001000,B10001000}
#define BE {B11111000,B10000000,B10000000,B11110000,B10000000,B11111000}
#define BH {B10001000,B10001000,B11111000,B10001000,B10001000,B10001000}
#define BI {B11111000,B00100000,B00100000,B00100000,B00100000,B11111000}
#define BS {B01110000,B10001000,B01100000,B00010000,B10001000,B01110000}
#define BD {B11110000,B10001000,B10001000,B10001000,B10001000,B11110000}
#define BY {B10001000,B01010000,B00100000,B00100000,B00100000,B00100000}
#define BP {B11110000,B10001000,B10001000,B11110000,B10000000,B10000000}
#define COMA{B00000000,B00000000,B00000000,B00110000,B00110000,B01100000}
#define SPACE{B00000000,B00000000,B00000000,B00000000,B00000000,B00000000}
#define NUM0{B01110000,B10011000,B10101000,B10101000,B11001000,B01110000}
#define NUM1{B00100000,B01100000,B10100000,B00100000,B00100000,B01110000}
#define NUM2{B01110000,B10001000,B00001000,B01110000,B10000000,B11111000}
#define NUM3{B11110000,B00001000,B00001000,B01111000,B00001000,B11110000}
#define NUM4{B10001000,B10001000,B10001000,B11111000,B00001000,B00001000}
#define NUM5{B11111000,B10000000,B11110000,B00001000,B10001000,B01110000}
#define NUM6{B11111000,B10000000,B11111000,B10001000,B10001000,B11111000}
#define NUM7{B11111000,B00001000,B00001000,B01111000,B00001000,B00001000}
#define NUM8{B11111000,B10001000,B11111000,B10001000,B10001000,B11111000}
#define NUM9{B11111000,B10001000,B11111000,B00001000,B00001000,B11111000}

byte humidityArray [12][6]= {BH,BU,BM,BI,BD,BI,BT,BY,SPACE,BI,BS,SPACE};
byte tempArray[8][6] = {BT,BE,BM,BP,SPACE,BI,BS};/*old array looked like {BT,BE,BM,BP,SPACE,BI,BS,SPACE}*/
byte numArray [10][6]={NUM0,NUM1,NUM2,NUM3,NUM4,NUM5,NUM6,NUM7,NUM8,NUM9};
byte newArray[100][6];
int key = 0;
int latchPin = 10;
int clockPin = 13;
int dataPin = 11;
int clock = 9;
int Reset = 8;
int latchPinPORTB = latchPin - 8;
int clockPinPORTB = clockPin - 8;
int dataPinPORTB = dataPin - 8;
int i = 0;
long scrolling_word[6];
int array_turn = 0;
int delay_langth;
void setup()
{
  Serial.begin(9600);
  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(latchPin, OUTPUT);
  pinMode(clock, OUTPUT);
  pinMode(Reset, OUTPUT);
  digitalWrite(Reset, HIGH);
  digitalWrite(Reset, LOW);
  setupSPI();
}
 void display_word(int loops,byte word_print[][6],int num_patterns,int delay_langth){// this function displays your symbols
  i = 0;// resets the counter fot the 4017
for(int b=0;b<10;b++)
{
  for(int n=0;n<8;n++)
  {
    Serial.print(word_print[b][n]);
    Serial.print("||");
  }
}
  for(int g=0;g<6;g++)//resets the the long int where your word goes
    scrolling_word[g] = 0;
  for(int x=0;x<num_patterns;x++)
  {//main loop, goes over your symbols
    for(int r=0;r<6;r++)//puts the buildes the first symbol
      scrolling_word[r] |= word_print[x][r]; 
    for (int z=0;z<6;z++)
        {//the sctolling action
            for(int p=0;p<6;p++)
              scrolling_word[p] = scrolling_word[p] << 1;
                // end of the scrolling funcion
          for(int t=0;t<delay_langth;t++)
                {// delay function for slower image increas delay_langth
                  for(int y=0;y<6;y++){// scaning the display
                    if(i == 6)
                    {  // counting up to 6 with the 4017
                      digitalWrite(Reset,HIGH);
                      digitalWrite(Reset,LOW);
                      i = 0;
                    }
                    latchOff();
                    spi_transfer(make_word(0x01000000,y));// sending the data
                    spi_transfer(make_word(0x00010000,y));
                    spi_transfer(make_word(0x00000100,y));
                    latchOn();
                    delayMicroseconds(800);//waiting a bit
                    latchOff();
                    spi_transfer(0);// clearing the data
                    spi_transfer(0);
                    spi_transfer(0);
                    latchOn();
                    digitalWrite(clock,HIGH);//counting up with the 4017
                    digitalWrite(clock,LOW);
                    i++;
                  }
              }
        }
  }
  finish_scroll(delay_langth);// zabavq bqgashtiq teks pri uveli4avane !!!!
}

void finish_scroll(int delay_scroll){// this function is the same as the funcion above, it just finishing scrolling 
  for (int n=0;n<24;n++){
        for(int h=0;h<6;h++)
          scrolling_word[h] = scrolling_word[h] << 1;
      for(int w=0;w<delay_scroll;w++){
        for(int k=0;k<6;k++){
          if(i == 6){
            digitalWrite(Reset,HIGH);
            digitalWrite(Reset,LOW);
            i = 0;
          }
          latchOff();
          spi_transfer(make_word(0x01000000,k));
          spi_transfer(make_word(0x00010000,k));
          spi_transfer(make_word(0x00000100,k));
          latchOn();
          delayMicroseconds(800);
          latchOff();
          spi_transfer(0);
          spi_transfer(0);
          spi_transfer(0);
          latchOn();
          digitalWrite(clock,HIGH);
          digitalWrite(clock,LOW);
          i++;
        }
      }
    }
}

byte make_word (long posistion,byte turn)
{
  byte dummy_word = 0;
  for(int q=0;q<8;q++)
  {
    if(scrolling_word[turn] & (posistion<<q))
      dummy_word |= 0x01<<q;
  }
  return dummy_word;
}   


  void loop() 
  {
   
    int tempVal= 12;
    int firstNum=tempVal/10;
    int secondNum= tempVal%10;
    /*
    float num=45.8;
    int numInt;
    numInt=int(num);
    Serial.print("numInt is:");
    Serial.println(numInt);*/
        for(int a=0;a<10;a++)
    {
      switch (a)
     {
      case 0:
      for(int b=0;b<6;b++)
      newArray[a][b]=tempArray[a][b];
      break;
      case 1:
      for(int b=0;b<6;b++)
      newArray[a][b]=tempArray[a][b];
      break;
      case 2:
      for(int b=0;b<6;b++)
      newArray[a][b]=tempArray[a][b];
      break;
      case 3:
      for(int b=0;b<6;b++)
      newArray[a][b]=tempArray[a][b];
      break;
      case 4:
      for(int b=0;b<6;b++)
      newArray[a][b]=tempArray[a][b];
      break;
      case 5:
      for(int b=0;b<6;b++)
      newArray[a][b]=tempArray[a][b];
      break;
      case 6:
      for(int b=0;b<6;b++)
      newArray[a][b]=tempArray[a][b];
      break;
      case 7:
      for(int b=0;b<6;b++)
      newArray[a][b]=tempArray[a][b];
      break;
      case 8:
      for(int b=0;b<6;b++)
      newArray[a][b]=numArray[firstNum][b];
      break;
      case 9:
      for(int b=0;b<6;b++)
      newArray[a][b]=numArray[secondNum][b];
      break;
     }
       array_turn=10;
      
     
  }
   display_word(1,newArray, array_turn, 32     );
  }
void latchOn(){
  bitSet(PORTB,latchPinPORTB);
}

void latchOff(){
  bitClear(PORTB,latchPinPORTB);
}


void setupSPI(){
  byte clr;
  SPCR |= ( (1<<SPE) | (1<<MSTR) ); // enable SPI as master
  //SPCR |= ( (1<<SPR1) | (1<<SPR0) ); // set prescaler bits
  SPCR &= ~( (1<<SPR1) | (1<<SPR0) ); // clear prescaler bits
  clr=SPSR; // clear SPI status reg
  clr=SPDR; // clear SPI data reg
  SPSR |= (1<<SPI2X); // set prescaler bits
  //SPSR &= ~(1<<SPI2X); // clear prescaler bits

  delay(10);
}
byte spi_transfer(byte data)
{
  SPDR = data;        // Start the transmission
  while (!(SPSR & (1<<SPIF)))     // Wait the end of the transmission
  {
  };
  return SPDR;        // return the received byte, we don't need that
}

I solved my problem, but i don’t understand why it happens.
When i removed “Space” from “tempArray” everything worked fine.

@Jikata, please do not cross-post. Threads merged.

        for(int a=0;a<10;a++)
    {
      switch (a)
     {
      case 0:

It is pointless to use a for loop when every iteration of the loop does something different.

Except that in every case, THE EXACT SAME THING HAPPENS. Your code needs some serious rework.

byte numArray [10][6] = {NUM0, NUM1, NUM2, NUM3, NUM4, NUM5, NUM6, NUM7, NUM8, NUM9};
byte newArray[100][6];

    for (int b = 0; b < 8; b++)
    {
        newArray[a][b] = numArray[firstNum][b] ;
    }

You seem to be using 8 elements from a 6 element array. That is seldom right.