Go Down

Topic: Dim LED Matrix (Read 987 times) previous topic - next topic

cubemike99

Hi. Im using a 8x8 matrix with the Arduino RowColumnScanning example sketch (with slight modification). Its working "fine," but the LED's are MUCH dimmer than they are when they are manually set. Anybody know what's causing this?

Code: [Select]
const int col[8] = {
 [glow]2,3,4,5,6,7,8,9[/glow] };

const int row[8] = {
 [glow]10,11,12,13,16,17,18,19[/glow]  };

int pixels[8][8];          

int x = 5;
int y = 5;

void setup() {
 for (int thisPin = 0; thisPin < 8; thisPin++) {

   pinMode(col[thisPin], OUTPUT);
   pinMode(row[thisPin], OUTPUT);  

   digitalWrite(col[thisPin], HIGH);    
 }

 for (int x = 0; x < 8; x++) {
   for (int y = 0; y < 8; y++) {
     pixels[x][y] = HIGH;
   }
 }
}

void loop() {
 readSensors();

 refreshScreen();
}

void readSensors() {

 pixels[x][y] = HIGH;

 x = map(analogRead(A0), 0, 1023, 0, 7);
 y =7- map(analogRead(A1), 0, 1023, 0, 7);

 pixels[x][y] = LOW;

}

void refreshScreen() {

 for (int thisRow = 0; thisRow < 8; thisRow++) {

   digitalWrite(row[thisRow], HIGH);

   for (int thisCol = 0; thisCol < 8; thisCol++) {

     int thisPixel = pixels[thisRow][thisCol];

     digitalWrite(col[thisCol], thisPixel);

     if (thisPixel == LOW) {
       digitalWrite(col[thisCol], HIGH);
     }
   }

   digitalWrite(row[thisRow], LOW);
 }
}

MarkT

You forgot to delay after switching the LEDs so you're switching them off again really fast.  Try something like 1ms delay in first instance.
[ I won't respond to messages, use the forum please ]

cubemike99

Thanks for the reply but Im not sure what you mean by first instance

James C4S

You want the lights to stay on for a some amount of time before you shut them back off again.  Your eyes are much (much) slower than the arduino.  You'll be surprised what a small delay like 1ms will do.

Before you turn the ROW off, delay for some amount of time.  Play with this delay to strike a balance between brightness and responsiveness.
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Go Up