Pages: [1]   Go Down
Author Topic: Dim LED Matrix  (Read 922 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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);
  }
}
Logged

0
Offline Offline
Shannon Member
****
Karma: 200
Posts: 11694
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

[ I won't respond to messages, use the forum please ]

0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Austin, TX
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6133
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Pages: [1]   Go Up
Jump to: