Close

Building the Firmware

A project log for LED BLE Hearty Necklace/Badge

8*16 LED matrix display with bluetooth low energy to connect to any smart phone

nitesh-kadyanNitesh Kadyan 04/03/2018 at 05:090 Comments

FIRMWARE:

Each character to be displayed is stored as 8 bytes in the program memory of ATMEGA. For example char 'A' is stored in 8 bytes as:

0b00001110, 
0b00010001,
0b00010001, 
0b00010001,
0b00011111, 
0b00010001,
0b00010001, 
0b00010001

You can see the arrangement of 1s in the above array forms the character 'A'. The complete text is displayed in a row scanning mode where each row is scanned for a very short amount of time and the columns are fed with a the appropriate bytes. By quickly scanning across the rows, and turning on the respective LEDs in each column of that row, the persistence of vision comes in to play, and we perceive the displayed image as still.

A buffer variable is maintained which stores the characters currently displayed.

unsigned int DisplayBuffer[][8] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}; 

To scroll the text this buffer variable is shifted left after every few milliseconds and new data is fed into the buffer from the right.

if(Serial.available() > 0){
      message = Serial.readString();
   }
  StringLength = message.length() ;

  for (k = 0; k < StringLength; k++) {
    for (scroll = 0; scroll < (8 / shift_step); scroll++) {
      for (ShiftAmount = 0; ShiftAmount < 8; ShiftAmount++) {

        DisplayBuffer[0][ShiftAmount] <<= 1;
        if (DisplayBuffer[1][ShiftAmount] & 0x80) {
          DisplayBuffer[0][ShiftAmount] |= 1;
        }

        index = message[k];
        temp = pgm_read_byte_near(&Data[index - 32][ShiftAmount]);
        DisplayBuffer[1][ShiftAmount] = (DisplayBuffer[1][ShiftAmount] << shift_step) | (temp >> ((8 - shift_step) - scroll * shift_step));
      }

      speed = 10;
      for (l = 0; l < speed; l++) {
        for (i = 0; i < 8; i++) {
          write595(DisplayBuffer[0][i]);
          write595(DisplayBuffer[1][i]);
          delayMicroseconds(50);
          digitalWrite(rowPins[row], HIGH);
          delay(1);
          digitalWrite(rowPins[row], LOW);
          row++;
          if (row >= 8)
            row = 0;
        }
      }
    }
  }

Two firmware boot on the first soldered board:

Discussions