error: expected unqualified-id before 'int'

I am sorry if i have posted this in the wrong place i am new to Arduino and the forum. I have been working with driving an 8x8 dot matrix LED display. It is wired up and everything, i have an Arduino Mega. I have gotten code offline someone else wrote and even gave the Schematic to the device i have wired up but when i try to compile it i get this:

In file included from /Users/tylerlavite/Desktop/arduino-0015/hardware/cores/arduino/WProgram.h:4,

/Users/tylerlavite/Desktop/arduino-0015/hardware/tools/avr/bin/…/lib/gcc/avr/4.3.2/…/…/…/…/avr/include/stdlib.h:111: error: expected unqualified-id before ‘int’

/Users/tylerlavite/Desktop/arduino-0015/hardware/tools/avr/bin/…/lib/gcc/avr/4.3.2/…/…/…/…/avr/include/stdlib.h:111: error: expected `)’ before ‘int’

/Users/tylerlavite/Desktop/arduino-0015/hardware/tools/avr/bin/…/lib/gcc/avr/4.3.2/…/…/…/…/avr/include/stdlib.h:111: error: expected `)’ before ‘int’

In file included from /Users/tylerlavite/Desktop/arduino-0015/hardware/cores/arduino/WProgram.h:6,

Here is the code:

/*

  • Show messages on an 8x8 led matrix,
  • scrolling from right to left.
  • Uses FrequencyTimer2 library to
  • constantly run an interrupt routine
  • at a specified frequency. This
  • refreshes the display without the
  • main loop having to do anything.

*/

#include <FrequencyTimer2.h>

#define SPACE {
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0}
}

#define H {
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0}
}

#define E {
{0, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 1, 1, 1, 1, 1, 0}
}

#define L {
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 1, 1, 1, 1, 1, 0}
}

#define O {
{0, 0, 0, 1, 1, 0, 0, 0},
{0, 0, 1, 0, 0, 1, 0, 0},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 0, 1, 0, 0, 1, 0, 0},
{0, 0, 0, 1, 1, 0, 0, 0}
}

byte col = 0;
byte leds[8][8];

// pin[xx] on led matrix connected to nn on Arduino (-1 is dummy to make array start at pos 1)
int pins[17]= {-1, 5, 4, 3, 2, 14, 15, 16, 17, 13, 12, 11, 10, 9, 8, 7, 6};

// col[xx] of leds = pin yy on led matrix
int cols[8] = {pins[13], pins[3], pins[4], pins[10], pins[06], pins[11], pins[15], pins[16]};

// row[xx] of leds = pin yy on led matrix
int rows[8] = {pins[9], pins[14], pins[8], pins[12], pins[1], pins[7], pins[2], pins[5]};

const int numPatterns = 6;
byte patterns[numPatterns][8][8] = {
H,E,L,L,O,SPACE
};

int pattern = 0;

void setup() {
// sets the pins as output
for (int i = 1; i <= 16; i++) {
pinMode(pins*, OUTPUT);*

  • }*
  • // set up cols and rows*
  • for (int i = 1; i <= 8; i++) {*
  • digitalWrite(cols[i - 1], LOW);*
  • }*
  • for (int i = 1; i <= 8; i++) {*
  • digitalWrite(rows[i - 1], LOW);*
  • }*
  • clearLeds();*
  • // Turn off toggling of pin 11*
  • FrequencyTimer2::disable();*
  • // Set refresh rate (interrupt timeout period)*
  • FrequencyTimer2::setPeriod(2000);*
  • // Set interrupt routine to be called*
  • FrequencyTimer2::setOnOverflow(display);*
  • setPattern(pattern);*
    }
    void loop() {
  • pattern = ++pattern % numPatterns;*
  • slidePattern(pattern, 60);*
    }
    void clearLeds() {
  • // Clear display array*
  • for (int i = 0; i < 8; i++) {*
  • for (int j = 0; j < 8; j++) {*
    _ leds*[j] = 0;_
    _
    }_
    _
    }_
    _
    }_
    void setPattern(int pattern) {
    _
    for (int i = 0; i < 8; i++) {_
    _
    for (int j = 0; j < 8; j++) {_
    leds_[j] = patterns[pattern][j];
    }
    }
    }
    void slidePattern(int pattern, int del) {
    for (int l = 0; l < 8; l++) {
    for (int i = 0; i < 7; i++) {
    for (int j = 0; j < 8; j++) {
    leds[j] = leds[j][i+1];
    }
    }
    for (int j = 0; j < 8; j++) {
    leds[j][7] = patterns[pattern][j][0 + l];
    }
    delay(del);
    }
    }
    // Interrupt routine*

    void display() {
    * digitalWrite(cols[col], LOW); // Turn whole previous column off*
    * col++;
    if (col == 8) {
    col = 0;
    }
    for (int row = 0; row < 8; row++) {
    if (leds[col][7 - row] == 1) {
    digitalWrite(rows[row], LOW); // Turn on this led*

    * }
    else {
    digitalWrite(rows[row], HIGH); // Turn off this led*

    * }
    }
    digitalWrite(cols[col], HIGH); // Turn whole column on at once (for equal lighting times)
    delayMicroseconds(900); // Delay so that on times are longer than off time = brighter leds*

    }
    Any help would be much appreciated i am so lost and confused._

You could try this:

The following changes to FrequencyTimer2 should get it to compile in 0015:

In FrequencyTimer2.h, replace the line
#include <wiring.h>
with
#include <inttypes.h>
And put the line
#include <wiring.h>
into to FrequencyTimer2.cpp (just after the #include <FrequencyTimer2.h>

taken from here: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1239820770/4#4

Stuff has changed in the Arduino libraries since FrequencyTimer2 was written. Also I don’t know if this will be sufficient to make it work as the Mega has a different processor than the ATMega168 that was current when the lib came out.

Andrew

Andrew, you left out an important part of the change mentioned in the linked post. The processor type needs to be added to the cpp file.

I have not tested this but try adding this to the cpp file:

if defined(AVR_ATmega1280)

define AVR_ATmega168

endif

I left it out deliberately as I didn't know what processor the Mega uses but I knew it wasn't an ATMega328. Maybe I should have left it in but noted that it would need changing.

Andrew

The cpp file is currently coded to default to the ATmega8, so every new chip needs to have a line added to the CPP file. It really should change to default to a 168 so the 328 (and I think the Mega) will work. Perhaps if someone can test the changes above on a mega, a revised version can be posted in the playground.

Wow thanks for all of the replies... i have school in about a half hour but i will try the suggestions and report back this afternoon.

Andrew i did your suggestion and sure enough it compiles with no errors at all now and sends the code to the board. Only problem is the board don't seem to be running the code. could that possibly be because the processor is not defined?

I know the Matrix is hooked up correctly.

Question about the .CPP file for "MEM" : You said to define the CPU type since it defaults to the older Atmega chip but where do i enter the code you posted? this is what's in the .cpp file that resembles the code you posted

if defined(AVR_ATmega168)

SIGNAL(SIG_OUTPUT_COMPARE2A)

else

SIGNAL(SIG_OUTPUT_COMPARE2)

endif

{

do i replace that with:

I have not tested this but try adding this to the cpp file:

if defined(AVR_ATmega1280)

define AVR_ATmega168

endif

Thanks guys for all of the replies this community is great!

you add the lines to the cpp file, you can them before the first of the exisiting #if defined .... lines

if defined(AVR_ATmega1280)

define AVR_ATmega168

endif