ok, so i've put it all together, and i've done the array issue.
i can't seem to find the maths basics still, so ill explain where i'm up to.
here's my current code.
this sets up the pins, sets up the array, and then uses the maths to do an UP count and a DOWN count, and then makes the top and bottom row do a simple cylon movement...
...but this is a complete ball-ache on how to set programs, and its really fussy on how to light an led without moving...
it also doesn't look like good practice!
for a start, i want to highlight;
0,0 to 0,8; then 0,8 to 8,8; then 8,8 to 8,0; then 8,0 to 0,0
or in other words, just to create a box on my matrix!
just a bit of direction going forward please!
int timer = 20; // The higher the number, the slower the timing.
int timer2 = 10;
int ledPinsROW[] = {
6, 7, 8, 9, 10, 11, 12, 13 }; // an array of pin numbers to which LEDs are attached
int ledPinsCOL[] = {
A5, A4, A3, A2, 2, 3, 4, 5 }; // an array of pin numbers to which LEDs are attached
int pinCount = 8; // the number of pins (i.e. the length of the array)void setup() {
int thisPinROW;
// the array elements are numbered from 0 to (pinCount - 1).
// use a for loop to initialize each pin as an output:
for (int thisPinROW = 0; thisPinROW < pinCount; thisPinROW++) {
pinMode(ledPinsROW[thisPinROW], OUTPUT);
}int thisPinCOL;
// the array elements are numbered from 0 to (pinCount - 1).
// use a for loop to initialize each pin as an output:
for (int thisPinCOL = 0; thisPinCOL < pinCount; thisPinCOL++) {
pinMode(ledPinsCOL[thisPinCOL], OUTPUT);
}
}void loop () {
//count up
for (int thisPinUP = 0; thisPinUP < pinCount; thisPinUP++) {// turn the pins on
digitalWrite(ledPinsROW[thisPinUP], HIGH);
digitalWrite(ledPinsCOL[0], HIGH);
digitalWrite(ledPinsCOL[pinCount - 1], HIGH);
delay(timer);
//turn the pins off
digitalWrite(ledPinsROW[thisPinUP], LOW);
digitalWrite(ledPinsCOL[thisPinUP], LOW);
delay(timer);
}//count down
for (int thisPinDN = pinCount; thisPinDN > 0; thisPinDN--) {digitalWrite(ledPinsROW[thisPinDN], HIGH);
digitalWrite(ledPinsCOL[0], HIGH);
digitalWrite(ledPinsCOL[pinCount - 1], HIGH);
delay(timer);
digitalWrite(ledPinsROW[thisPinDN], LOW);
delay(timer);
}
// end of program curly brckets
}