Sketch errors out at first "show"

This is copied form the "Arduino Cookbook" Sketch 7.8. For some reason the first instance of the word show gives me a fault. Any help is appreciated.

/*matrixMpxAnimation
   animates two heart images to show a beating heart
*/

// the heart images are stored as bitmaps - each bit corresponds to an LED
// a 0 indicates the LED is off, 1 is on
byte bigHeart[] = {
  B01100110,
  B11111111,
  B11111111,
  B11111111,
  B01111110,
  B00111100,
  B00011000,
  B00000000
};

byte smallHeart[] = {
  B00000000,
  B00000000,
  B00010100,
  B00111110,
  B00111110,
  B00011100,
  B00001000,
  B00000000
};

const int columnPins[]   = {  2,  3,  4,  5,  6,  7,  8,  9};
const int rowPins[]      = { 10, 11, 12, 15, 16, 17, 18, 19};


void setup() {
  for (int i = 0; i < 8; i++)
  {
    pinMode(rowPins[i], OUTPUT);
    pinMode(columnPins[i], OUTPUT);
    digitalWrite(columnPins[i], HIGH);
  }
}

void loop() {
  int pulseDelay = 800 ;

  show(smallHeart, 80);
  show(bigHeart, 160);
  delay(pulseDelay);
}


{
  unsigned long start = millis();
  while (start + duration millis())
  {
    for (int row = 0; row < 8; row++)
    {
      digitalWrite(rowPins[row], HIGH);
      for (int column = 0; column < 8; column++);
      {
        boolean pixel = bitRead(image[row], column);
        if (pixel == 1)
        { digitalWrite(columnPins[column], LOW);
        }
        delayMicroseconds(300);
        digitalWrite(columnPins[column, HIGH);
      }
      digitalWrite(rowPins[row], LOW);
    }
  }
}

You are missing some code:

// routine to show a frame of an image stored in the array pointed to by the 
// image parameter. 
// the frame is repeated for the given duration in milliseconds 
void show( byte * image, unsigned long duration)

Once again I'm in your debt. Thanks.

I still have a problem. I know that we talked about brackets, but I think that is the problem but I can't find it.

Here is the code.

/*matrixMpxAnimation
   animates two heart images to show a beating heart
*/

// the heart images are stored as bitmaps - each bit corresponds to an LED
// a 0 indicates the LED is off, 1 is on
byte bigHeart[] = {
  B01100110,
  B11111111,
  B11111111,
  B11111111,
  B01111110,
  B00111100,
  B00011000,
  B00000000
};

byte smallHeart[] = {
  B00000000,
  B00000000,
  B00010100,
  B00111110,
  B00111110,
  B00011100,
  B00001000,
  B00000000};

const int columnPins[]   = {  2,  3,  4,  5,  6,  7,  8,  9};
const int rowPins[]      = { 10, 11, 12, 15, 16, 17, 18, 19};


void setup() {
  for (int i = 0; i < 8; i++)
  {
    pinMode(rowPins[i], OUTPUT);       // make all the LED pins outputs
    pinMode(columnPins[i], OUTPUT);
    digitalWrite(columnPins[i], HIGH); // disconnect column pins from Ground
  }
}

void loop() {
  int pulseDelay = 800 ;       // millisconds to wait between beats

  show(smallHeart, 80);        // show the small heat image for 100 ms
  show(bigHeart, 160);         // followed by the big heart for 200 ms
  delay(pulseDelay);           // showing nothing between beats
}

// routine to show a fram of an image stored in the array pointed to by  the
// image parameter.
//the frame is repeated for the given duration in milliseconds
void show( byte * image, unsigned long duration)
{
  unsigned long start = millis();          // begin timing the animation
  while (start + duration > millis())      // loop until the duration period
    // hass passed
  {
    for (int row = 0; row < 8; row++)
    {
      digitalWrite(rowPins[row], HIGH);          // connect row to +5 volts
      for (int column = 0; column < 8; column++);
     {
        boolean pixel = bitRead(image[row],column);
        if (pixel == 1)
        {
          digitalWrite(columnPins[column], LOW);   // connect column to Grd
        }
        delayMicroseconds(300);                    // a small delay for each LED
        digitalWrite(columnPins[column, HIGH);     // disconnect column from from Grd
      }
      digitalWrite(rowPins[row], LOW);             // disconnect LEDS
    }
  }
}

digitalWrite(columnPins[column, HIGH); // disconnect column from from Grd

Change to:

digitalWrite(columnPins[column], HIGH); // disconnect column from from Grd
.

I found that too, but still have the same error.

This line should not have a semicolon at the end:

     for (int column = 0; column < 8; column++);

But that is not causing the error. Are you hand typing the code from a book? I didn't think anyone did that since the 1980s!

If you still have the error, do an Autoformat a d re-post the sketch. Also post the error message.

Thank you PaulRB.

I was going blind looking at everything.

I understand the need for what I call punctuation. but it sure can make life difficult.

Once again thanks to all who look and tried.

Post close

By the way thanks for that tip on CTRL T

Zip of all code:

Or it is attached in PDF file below:
.

ArduinoCookbook2E.zip (265 KB)

If you click on an opening brace { then the matching closing brace } will be highlited. Do this to make sure that the braces enclose the code you think it should.
The same goes for brackets ( )

Both programs for the Arduino Cookbook will compile, The 8 x 8 display all the leds will light at the same time. I have check my wiring against figure 7-8. I'm using 1K resister, I have no 680 ohm. I have written a sketch to test the board at a very simple basic level. the sketch compiles but wills to light the leds.

const int columnPins[] = {2, 3, 4, 5, 6, 7, 8, 9};
const int rowPins[] = {10, 11, 12, 15, 16, 17, 18, 19};



void setup() {

  pinMode(rowPins[10], OUTPUT);
  pinMode(rowPins[11], OUTPUT);
  pinMode(rowPins[12], OUTPUT);
  pinMode(rowPins[15], OUTPUT);
  pinMode(rowPins[16], OUTPUT);
  pinMode(rowPins[17], OUTPUT);
  pinMode(rowPins[18], OUTPUT);
  pinMode(rowPins[19], OUTPUT);

  pinMode(columnPins[2], OUTPUT);
  pinMode(columnPins[3], OUTPUT);
  pinMode(columnPins[4], OUTPUT);
  pinMode(columnPins[5], OUTPUT);
  pinMode(columnPins[6], OUTPUT);
  pinMode(columnPins[7], OUTPUT);
  pinMode(columnPins[8], OUTPUT);
  pinMode(columnPins[9], OUTPUT);
}
void loop() {
 
  digitalWrite(rowPins[10], HIGH);
  digitalWrite(rowPins[11], HIGH);
  digitalWrite(rowPins[12], HIGH);
  digitalWrite(rowPins[15], HIGH);
  digitalWrite(rowPins[16], HIGH);
  digitalWrite(rowPins[17], HIGH);
  digitalWrite(rowPins[18], HIGH);
  digitalWrite(rowPins[19], HIGH);

  digitalWrite(columnPins[3], HIGH);
  digitalWrite(columnPins[4], HIGH);
  digitalWrite(columnPins[5], HIGH);
  digitalWrite(columnPins[6], HIGH);
  digitalWrite(columnPins[7], HIGH);
  digitalWrite(columnPins[8], HIGH);
  digitalWrite(columnPins[9], HIGH);

  delay( 2000);

  digitalWrite(rowPins[10], LOW);
  digitalWrite(rowPins[11], LOW);
  digitalWrite(rowPins[12], LOW);
  digitalWrite(rowPins[15], LOW);
  digitalWrite(rowPins[16], LOW);
  digitalWrite(rowPins[17], LOW);
  digitalWrite(rowPins[18], LOW);
  digitalWrite(rowPins[19], LOW);

  digitalWrite(columnPins[2], LOW);
  digitalWrite(columnPins[3], LOW);
  digitalWrite(columnPins[4], LOW);
  digitalWrite(columnPins[5], LOW);
  digitalWrite(columnPins[6], LOW);
  digitalWrite(columnPins[7], LOW);
  digitalWrite(columnPins[8], LOW);
  digitalWrite(columnPins[9], LOW);

  delay( 2000);
}
OK I rewrote the program. 

[codeconst int column2 = 2;
const int column3 = 3;
const int column4 = 4;
const int column5 = 5;
const int column6 = 6;
const int column7 = 7;
const int column8 = 8;
const int column9 = 9;
const int row10 = 10;
const int row11 = 11;
const int row12 = 12;
const int row15 = 15;
const int row16 = 16;
const int row17 = 17;
const int row18 = 18;
const int row19 = 19 ;

void setup() {
  
  pinMode(column2, OUTPUT);
  pinMode(column3, OUTPUT);
  pinMode(column4, OUTPUT);
  pinMode(column5, OUTPUT);
  pinMode(column6, OUTPUT);
  pinMode(column7, OUTPUT);
  pinMode(column8, OUTPUT);
  pinMode(column9, OUTPUT);
  pinMode(row10, OUTPUT);
  pinMode(row11, OUTPUT);
  pinMode(row12, OUTPUT);
  pinMode(row15, OUTPUT);
  pinMode(row16, OUTPUT);
  pinMode(row17, OUTPUT);
  pinMode(row18, OUTPUT);
  pinMode(row19, OUTPUT);

}

void loop() {
  digitalWrite(column2, HIGH);
  digitalWrite(row15, HIGH);
  delay(1000);  
  digitalWrite(row15, LOW);
  digitalWrite(column5, LOW);
  
}]

With the number side down (pin 1) bottom left corner, leds in the right column are on at different brightness.

I don't have a copy of the book you referred to. Please post the schematic.

Are you using:

Yes that is the schematic. I have check my wiring several times. As mention I'm using 1K ohm resistors as I have no 680 ohm. I'm leaving right now to take wife t doctor will stop by radio shack and get some 680.

I don't think 680R vs 1K will make a difference. The sketch you posted should light a column except for one led only. The fact that the leds that are lit are not equal brightness makes me wonder if the Arduino or the matrix is damaged. Try swapping some of the Arduino pins around (colum pins with column pins or row pins with row pins). Does the pattern of dim leds correspond to particular Arduino pins?

Are you sure that you have the same type 8x8 matrix and not the other?

The Arduino has checked out fine. I program several LEDs to go on and off and they worked OK.

Is there a decent picture of the pinout for the 8x8 matrix. So I can be sure I have the right pins.

All matrices may not have the same pinout. Is there a model number printed on tbe side? Have you googled for that?

Yes I have the number is 1088AS. As far as I can tell I have the correct orientation of pins. Looking at the number side with the led up, pins down, pin #1 is the left pin bottom and #16 is left pin top. I amgoing to search for another 8x8 matrix.

You could test the matrix by not using the Arduino output pins, just the 5V and ground. Connect one row to 5V and all columns to ground via resistors. Try each row in turn. Do all leds light with equal brightness?