Hi all,
I'm new to the forums and it's good to be here!
So I've wired up 3 single colour LEDs and 3 push buttons.
At the moment my goal is to make the LEDs flash in a particular pattern, constantly. Later I hope to ask a participant to push the buttons in time with the LEDs but my first hurdle appears to be making the pattern work.
The pattern is very regular and loops ad infinitum. I found a tutorial about using arrays to make patterns (it was the KITT tutorial from Knight Rider) which makes the LEDs light up back and forth in a row. The pattern I have is more abstract than that and I found a tutorial that seemed to make it easy to do this, and ended up writing the code below.
const int ledPin1 = 10; //define the led pins
const int ledPin2 = 11;
const int ledPin3 = 12;
const int switchPin1 = 1; //define the button pins
const int switchPin2 = 2;
const int switchPin3 = 3;
int timer = 100; //set the speed for the pattern to be displayed
int ledPins[] = {10, 11, 12}; //define the led pins
int pinCount = 3; //define the number of leds
void setup()
{
int pinArray[8, 3] = //set the array as 8 rows and 3 columns
{
{1, 0, 0}, //define the pattern in which the leds should light up
{0, 1, 0},
{0, 0, 1},
{0, 1, 0},
{1, 0, 0},
{0, 1, 0},
{0, 0, 1},
{0, 1, 0}
}
pinMode(ledPin1, OUTPUT); //define the pin modes
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
pinMode(switchPin1, INPUT);
pinMode(switchPin2, INPUT);
pinMode(switchPin3, INPUT);
}
void loop()
{
for(row = 0; row <= 7; row ++) //tell the program to cycle through the rows of the array
{
digitalWrite(10, array[row, 0]);
digitalWrite(11, array[row, 1]);
digitalWrite(12, array[row, 2]);
delay(100);
}
}
I realise there might be more code than is necessary in it, and the pattern in the array is just a test. The error I keep getting out is this:
JGL_Code.cpp: In function 'void setup()':
JGL_Code:12: error: expected ]' before ',' token JGL_Code:12: error: expected unqualified-id before numeric constant JGL_Code:40: error: expected }' at end of input
directed at the line ' int pinArray[8, 3] ='
I'm sorry that the code is such a mess. I'm new to programming and at the moment I'm feeling my way through the tutorials. If anyone can help me out with this I'd be really grateful.
Happy to answer any questions...
Cheers!