I have a very simple task of running a 3 row (cathodes) by 4 Column (anodes) from top left to bottom right, only illuminating one LED at a time.
I do apologise about the length of my code and how simple this really is. I will appreciate anyone taking a look at my code for me. many thanks.
/* The aim is to make an LED MATRIX of 3 Rows by 4 Columns be illuminated from top left to bottom right, only illuminating one LED at a time. Like an LED test run.
*/
int rowPin1 = 9;
int rowPin2 = 8;
int rowPin3 = 7;
int timer = 100; // the time the LED will be on for.
int timer2 = 400; // the time a row takes to finnish a loop from left to right.
int timer3 = 800; // the time 2 rows take to finnish a loop from left to right.
void setup() {
//the columns (Anodes) will loop and switch from high to low at t = (timer), from left to right
(int thisPin = 2; thisPin < 6; thisPin++) {
pinMode(thisPin, OUTPUT);}
{
//set row pins as outputs and change whether they go high or low. The row that must be illuminated will have a low out put while the other 2 rows must be high.
pinMode(rowPin1, OUTPUT);
pinMode(rowPin2, OUTPUT);
pinMode(rowPin3, OUTPUT);
}
}
void loop()
{// colomn loop.
for (int thisPin = 2; thisPin < 6; thisPin++) {
pinMode(thisPin, OUTPUT);
digitalWrite(thisPin, HIGH);
delay(timer);
// turn the pin off:
digitalWrite(thisPin, LOW);
digitalWrite (rowPin1,LOW);
//row1(top row) must be low for the time it takes for the column loop to loop once.
delay (timer2);
//turn back high for the time it takes the other two rows to loop once.
digitalWrite (rowPin1,HIGH);
delay (timer3);
digitalWrite(rowPin2, HIGH);
//turn row2 high for the time it takes row1 to loop once.
delay (timer2);
digitalWrite(rowPin2, LOW);
//turn row2 low for the time it takes the columns to loop once.
delay (timer2);
digitalWrite(rowPin2, HIGH);
//turn row2 back high for the time it takes the other two rows to loop once.
delay (timer3);
digitalWrite(rowPin3, HIGH);
delay (timer3);
digitalWrite(rowPin3, LOW);
delay (timer2);
digitalWrite(rowPin3, HIGH);
delay (timer3);
}
my error message is always :
Arduino: 1.6.12 (Windows 10), Board: "Arduino/Genuino Uno"
expected primary-expression before 'int'
(int thisPin = 2; thisPin < 6; thisPin++) {
exit status 1
expected primary-expression before 'int' .
I have trouble knowing how many loops the 'void loop' heading should have under it before I rather run a separate loop.