Trying to create code for a bouncing ball on an 8x8 matrix. here is my code so far. I keep getting an error on my defintion of all my matricies.
It says "Arduino: 1.8.4 (Windows 10), Board: "Arduino/Genuino Uno"
C:\Users\Santiago\Desktop_8x8MatrixDisplay6_timerone_8x8MatrixDisplay6_timerone.ino:25:13: warning: backslash and newline separated by space
#define G { \
^
C:\Users\Santiago\Desktop_8x8MatrixDisplay6_timerone_8x8MatrixDisplay6_timerone.ino:37:13: warning: backslash and newline separated by space
#define h { \
^
C:\Users\Santiago\Desktop_8x8MatrixDisplay6_timerone_8x8MatrixDisplay6_timerone.ino:48:13: warning: backslash and newline separated by space
#define j { \
^
C:\Users\Santiago\Desktop_8x8MatrixDisplay6_timerone_8x8MatrixDisplay6_timerone.ino:59:14: warning: backslash and newline separated by space
#define k { \
^
C:\Users\Santiago\Desktop_8x8MatrixDisplay6_timerone_8x8MatrixDisplay6_timerone.ino:82:14: warning: backslash and newline separated by space
#define m { \
^
_8x8MatrixDisplay6_timerone:61: error: expected unqualified-id before '{' token
{0, 0, 0, 0, 0, 0, 0, 0}, \
^
_8x8MatrixDisplay6_timerone:61: error: expected unqualified-id before ',' token
{0, 0, 0, 0, 0, 0, 0, 0}, \
^
_8x8MatrixDisplay6_timerone:62: error: expected unqualified-id before '{' token
{0, 0, 0, 0, 0, 0, 0, 0}, \
^
_8x8MatrixDisplay6_timerone:62: error: expected unqualified-id before ',' token
{0, 0, 0, 0, 0, 0, 0, 0}, \
^
_8x8MatrixDisplay6_timerone:63: error: expected unqualified-id before '{' token
{0, 0, 0, 0, 0, 1, 0, 0}, \
^
_8x8MatrixDisplay6_timerone:63: error: expected unqualified-id before ',' token
{0, 0, 0, 0, 0, 1, 0, 0}, \
^
_8x8MatrixDisplay6_timerone:64: error: expected unqualified-id before '{' token
{0, 0, 0, 0, 0, 0, 0, 0}, \
^
_8x8MatrixDisplay6_timerone:64: error: expected unqualified-id before ',' token
{0, 0, 0, 0, 0, 0, 0, 0}, \
^
_8x8MatrixDisplay6_timerone:65: error: expected unqualified-id before '{' token
{0, 0, 0, 0, 0, 0, 0, 0}, \
^
_8x8MatrixDisplay6_timerone:65: error: expected unqualified-id before ',' token
{0, 0, 0, 0, 0, 0, 0, 0}, \
^
_8x8MatrixDisplay6_timerone:66: error: expected unqualified-id before '{' token
{0, 0, 0, 0, 0, 0, 0, 0}, \
^
_8x8MatrixDisplay6_timerone:66: error: expected unqualified-id before ',' token
{0, 0, 0, 0, 0, 0, 0, 0}, \
^
_8x8MatrixDisplay6_timerone:67: error: expected unqualified-id before '{' token
{0, 0, 0, 0, 0, 0, 0, 0}, \
^
_8x8MatrixDisplay6_timerone:67: error: expected unqualified-id before ',' token
{0, 0, 0, 0, 0, 0, 0, 0}, \
^
_8x8MatrixDisplay6_timerone:68: error: expected unqualified-id before '{' token
{0, 0, 0, 0, 0, 0, 0, 0} \
^
_8x8MatrixDisplay6_timerone:69: error: expected declaration before '}' token
}
^
exit status 1
expected unqualified-id before '{' token
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
"
#define F {
{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, 1, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0}
}
#define G { \
{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, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0}
}
#define h { \
{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, 1, 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 j { \
{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, 1, 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 k { \
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 1, 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 l {
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 1, 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 m { \
{0, 0, 0, 0, 0, 0, 0, 1},
{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}
}
const int row[8] = {
2,7,17,5,13,16,12,14 };
const int col[8] = {
6,11,10,3,15,4,8,9 };
volatile byte c,r,flag,counter;
volatile byte pattern[8][8]=E;
volatile byte pattern[8][8]=F;
volatile byte pattern[8][8]=G;
volatile byte pattern[8][8]=h;
volatile byte pattern[8][8]=j;
volatile byte pattern[8][8]=k;
volatile byte pattern[8][8]=l;
volatile byte pattern[8][8]=m;
byte pattern[8][8]=E;
unsigned long previousMillis =0;
unsigned long interval = 1000;
int currentPattern =0;
void setup() {
// initialize the row and column pins as outputs
// iterate through the pins:
for (int pin = 0; pin < 8; pin++) {
// initialize the output pins:
pinMode(col[pin], OUTPUT);
digitalWrite(col[pin], HIGH);
pinMode(row[pin], OUTPUT);
digitalWrite(row[pin], LOW);
// take the col pins (i.e. the cathodes) high and the row pins (anodes) low to ensure that
// the LEDS are off:
}
Timer1.initialize(100); // initialize timer1, and set a 100 us second period for the interrupt interval (i.e. the ISR will be called
//every 100 us - this seems to be a good frequency to achieve a flicker-free LED display.
//experiment with this parameter. If it gets too small the ISR starts 'eating up' all the processor time, and the main loop becomes very slow
Timer1.attachInterrupt(refreshScreen); // attaches the refreshScreen() function as 'Interrupt Service Routine' (ISR) to the interrupt
//this means that every time 100 us have passed, the refreshScreen() routine will be called.
}
}
//main loop...here we can simply busy ourselves with changing the pattern[][] array; nothing deals with the LED display.
//this is all handled via the ISR
void loop() {
unsigned long currentMillis = millis();
if(currentMIllis - previousMillis > interval)
{
if(currentPattern==0)
{
for(int i =0; i<8; i++)
{
for (int j=0; j<8;j++)
{
pattern_[j]=patternF*[j];_
_ delay(100);_
pattern_[j]=patternG[j];
delay(100);
pattern[j]=patternh[j];
delay(100);
pattern[j]=patternj[j];
delay(100);
pattern[j]=patternk[j];
delay(100);
pattern[j]=patternl[j];
delay(100);
pattern[j]=patternm[j];
}
}
currentPattern =1;
}*_
* //here we simply enter 1s and 0s into the pattern[][] array randomly. This causes a wild flickering of all the LEDs of the display*
* //just an example how you could play with the display in the main loop without having to worry about actually strobing the display LEDs.*
* //pattern[random(0, 8)][random(0, 8)]=1;//turn a random LED on*
* //pattern[random(0, 8)][random(0, 8)]=0;//turn a random LED off*
}
}