usb port speed (shift out) too slow?

hey all,

we got a problem: we have got like 200 leds connected to 24 IC's like explained in the shift out tutorials "Serial to Parallel Shifting-Out with a 74HC595" (

When running a program designed for testing our setup, we can easily light up every single LED using a 0.1s delay between two different states.

Now we have to connect the Arduino to the PC using USB and the COM-port-connection. Now the problem is: Arduino seems to properly receive every single command (indicated by the RX-LED on the board itself), but often seems to be too slow to forward them to the register. We are sending like six commands in a row with 0.5s delay in between of each transmission, and then having a break for like 5 secs. Only the last one of the six commands is processed by the register and forwarded to the register or even none of them...

We tried to raise the port speed from 9600 to something else - this does not seem to change anything - most speeds do not work anyway... But I don't know if that is the reason, because Arduinos RX-LED is blinking while receiving the command, but Arduino is not processing it nor answering...

Any ideas? Can paste the code if that helps...

Thanks a lot!

The code would help, yea. When you say that "most speeds do not work" what do you mean? What happens at higher speeds that shouldn't be?

This is some of the code we are using on the Arduino to receive data from the PC and to write it out to the register:

// read (and print back) full strings from the serial port
// for more info

boolean readSerialString () {
    int i = 0;
//    int n = 0;
    int z = 0;
    int myByte = 0;
    if(serialAvailable()) {    
       while (serialAvailable()){ 
         myByte = (serialRead() - '0') + myByte *10;
         if(i%3 == 0){
           dataArray[z] = myByte;
           myByte = 0;
       //   myByte = ;
   if(z == anzRegister){
      return true;
    }  else {
      return false;



void shiftOut(int myDataPin, int myClockPin, byte myDataOut) {
  // This shifts 8 bits out MSB first, 

void setup() {
  //set pins to output because they are addressed in the main loop
  pinMode(latchPin, OUTPUT);
  beginSerial(9600);  //setup serial conversation at 9600 bauds
    printString("Yes, I'm hearing you.");

void loop () {
  //try to read the serial port and create a string out of what you read
    printString("Arduino heard you.");
    int j = 0;
    digitalWrite(latchPin, 0);

    for (int b = 0; b < anzRegister; b++) {
            //jetzt das entsprechende feld aufleuchten lassen
            //ground latchPin and hold low for as long as you are transmitting
            //load the light sequence you want from array
            data = dataArray[b];
            shiftOut(dataPin, clockPin, data);
            //return the latch pin high to signal chip that it 
            //no longer needs to listen for information
       digitalWrite(latchPin, 1);
 // serInString[0] = 0;

What happens when it is working is this:

  1. PC sends command to Arduino
  2. Arduino RX flashes
  3. Arduino shifts out the information to the register
  4. Arduino TX flashes
  5. Arduino has replied with “heard you” which is received by the PC

What happens when it is not-working is:

  1. PC sends command to Arduino
  2. Arduino RX flashes
  3. — nothing else —

Sometimes it works, sometimes it doesn’t, even when running at the same port speed. It is working perfectly while using a program designed for testing the whole setup - manually. It is not working properly when information is sent by the main program in faster intervals of 0.5s…

We thought that might be connected to the port speed but that does not seem to change anything, or would it?


I suspect you are running into some timing issues associated with the digitalwrites in the old style shiftout. Shiftout is now included in Arduino, take a look here to see an example. The 595 tutorial has not been updated yet.