POV of 16 LEDs with shift register 595

I need to shift out 16 bits fast from arduino with two pair of 74HC595 shift register. I do some research that they said digitalWrite function is slow. Is that right ? I need to shift out 16bits fast to create the POV effect. Below is my source code. Please help me, i am stuck with that in a few days already.

int clockPin = 11;
int latchPin = 12;
int dataPin = 13;

String povtext = “TTT”;
byte refreshrate = 1;
int dimtext = povtext.length();

int letterT = {1,1,1,1,1,1,1,1, //display T
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
0,0,0,1,1,0,0,0,
0,0,0,1,1,0,0,0,
0,0,0,1,1,0,0,0,
0,0,0,1,1,0,0,0,
0,0,0,1,1,0,0,0,
0,0,0,1,1,0,0,0,
0,0,0,1,1,0,0,0,
0,0,0,1,1,0,0,0,
0,0,0,1,1,0,0,0,
0,0,0,1,1,0,0,0,
0,0,0,1,1,0,0,0,
0,0,0,1,1,0,0,0,
};

void setup() {
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}

void show (int LED[8]){
byte first;
byte second;
for (byte x=0; x<8; x++){
first = 0;
second = 0;
for (byte i=0; i<8; i++){
if (LED*==1){*

  • bitWrite(second,i,HIGH);*
  • }*
  • }*
  • for (byte k=8; k<16; k++){*
  • if (LED[k]==1){*
  • bitWrite(first,k,HIGH);*
  • }*
  • }*
  • digitalWrite(latchPin, LOW);*
  • shiftOut(dataPin, clockPin, MSBFIRST, second); //send byte to shift register*
  • shiftOut(dataPin, clockPin, MSBFIRST, first); // send byte to shift register*
  • digitalWrite(latchPin, HIGH); //tell shift register done sending data so it can enable output *
  • }*
    }
    void loop() {
    digitalWrite(latchPin, LOW); //off the led
    delay(refreshrate*3);
    *for (int n=0; n<dimtext; n++){ *
  • if(povtext.charAt(n)==‘T’){*
  • show(letterT);*
  • }*
  • else if(povtext.charAt(n)==’ '){ //for spacing in the text*
  • digitalWrite(latchPin, LOW);*
    _ delay(refreshrate*3);_
  • }*
  • digitalWrite(latchPin, LOW); //space between each character*
  • delay(refreshrate);*
    }
    digitalWrite(latchPin, LOW); //space at end of text
    delay(refreshrate*3);
    }
int letterT[]

Int? To hold 0 or 1? Why?

I do some research that they said digitalWrite function is slow. Is that right ?

What did that "research" suggest as the alternative? Why are you not using shiftOut()?

PaulS: int letterT[]

Int? To hold 0 or 1? Why? Led turn off when its 0 and on when its 1.

I do some research that they said digitalWrite function is slow. Is that right ?

What did that "research" suggest as the alternative? Why are you not using shiftOut()?

The website suggest using PORTB, PORTC, PORTD method. Mean that use all the i/o pin without shift register.

Use SPI.transfer for fast sending to 74HC595. Set spi divisor to 2, blast out data a 8 MHz speed.

digitalWrite (ssPin, LOW); SPI.transfer(highByte (data_as_int)); SPI.transfer(lowByte(data_as_int)); digitalWrite (ssPin, HIGH);

I would also re-do your fonts. Look at your T as 8 columns, with an int per column: int letterT[] = { 0b1111000000000000, 0b1111000000000000, 0b1111000000000000, 0b1111111111111111; 0b1111111111111111; 0b1111000000000000, 0b1111000000000000, 0b1111000000000000, };

That gets rid of a lot of other code, as now you just need the SPI.transfes above with whatever timing you need for POV. Also saves a lot of memory as a letter now is just 16 bytes.