8x8 Bouncing Ball

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*
}
}

@pert says it better then I would have.

pert:
Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is that the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. If your browser doesn't show the posting toolbar then you can just manually add the code tags:

[code]

[color=blue]// your code is here[/color]

[/code]

Using code tags and other important information is explained in the How to use this forum post. Please read it.

Please always do a Tools > Auto Format on your code before posting it. This will make it easier for you to spot bugs and make it easier for us to read. If you're using the Arduino Web Editor you will not have access to this useful tool but it's still unacceptable to post poorly formatted code. I recommend you to use the standard IDE instead.

Please remove unnecessary blank lines from your code before posting to the forum. One or two to separate code into logical sections is fine but large spaces for no reason or random blank lines just make for more scrolling when we're trying to read your code.

I would add to use a separate set of code tags for your error messages also.

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks. Tom.. :slight_smile:

Even if your #defines worked what do you imagine this section of code would do ?

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;

Hi,
It looks like you are trying to display a bouncing ball by loading pre-made screens.

As the display is only 8 x 8, surely you can code an algorithm that bounces the ball and save all the possible screens you will need.

Tom... :slight_smile: