you want to light up a whole row - or column
really? How? I mean I am not able to understand the concept, we give HIGH on row A and give LOW on row 1, it will light up just 1 LED.. how does a whole row light up comes in? (Am I missing some basic electronic stuff? )
You do not turn it off on exit. You leave it on until you enter the routine again to change it.
If I do not turn an LED off at the last statement of the loop (of scan routine), how will the next LED be turned on on the next iteration of the loop? (one LED light up at one time..small delay..then other..small delay..then other LED...so on..)
Just to make sure I and you both are on the same page, let me paste the reference code which I am using and trying to modify. It's from Arduino CookBook.
/*
* matrixMpxAnimation sketch
* animates two heart images to show a beating heart
*/
// the heart images are stored as bitmaps - each bit corresponds to an LED
// a 0 indicates the LED is off, 1 is on
byte bigHeart[] = {
B01100110,
B11111111,
B11111111,
B11111111,
B01111110,
B00111100,
B00011000,
B00000000};
byte smallHeart[] = {
B00000000,
B00000000,
B00010100,
B00111110,
B00111110,
B00011100,
B00001000,
B00000000};
const int columnPins[] = { 2, 3, 4, 5, 6, 7, 8, 9};
const int rowPins[] = { 10,11,12,15,16,17,18,19};
void setup() {
for (int i = 0; i < 8; i++)
{
pinMode(rowPins[i], OUTPUT); // make all the LED pins outputs
pinMode(columnPins[i], OUTPUT);
digitalWrite(columnPins[i], HIGH); // disconnect column pins from Ground
}
}
void loop() {
int pulseDelay = 800 ; // milliseconds to wait between beats
show(smallHeart, 80); // show the small heart image for 100 ms
show(bigHeart, 160); // followed by the big heart for 200ms
delay(pulseDelay); // show nothing between beats
}
// routine to show a frame of an image stored in the array pointed to by the
// image parameter.
// the frame is repeated for the given duration in milliseconds
void show( byte * image, unsigned long duration)
{
unsigned long start = millis(); // begin timing the animation
while (start + duration > millis()) // loop until the duration period
has passed
{
for(int row = 0; row < 8; row++)
{
digitalWrite(rowPins[row], HIGH); // connect row to +5 volts
for(int column = 0; column < 8; column++)
{
boolean pixel = bitRead(image[row],column);
if(pixel == 1)
{
digitalWrite(columnPins[column], LOW); // connect column to Gnd
}
delayMicroseconds(300); // a small delay for each LED
digitalWrite(columnPins[column], HIGH); // disconnect column from Gnd
}
digitalWrite(rowPins[row], LOW); // disconnect LEDs
}
}
}