Pages: [1]   Go Down
Author Topic: LED matrix, different brightness  (Read 641 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 53
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,
in my 10 x 11 matrix occurs a (for me) strange thing: Although the anodes are supplied with  Darlington-Arrays (to strengthen the signal form Arduino Uno) (UDN2981A), the 9th row is the brightest. I usually wanted all LEDs with this brightness, but the others are all darker.

Who can help me?
Thanks!
Logged

SE USA
Offline Offline
Faraday Member
**
Karma: 41
Posts: 3783
@ssh0le
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

without seeing a circuit, or code a guess is the best you can hope for, I guess that its pausing for a moment on row 9
Logged


Offline Offline
Jr. Member
**
Karma: 0
Posts: 53
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry for my late answer, here's the code. May it occur because of my "time- asking"? I'm using RTClib.h and I am always asking for the time at the beginning of the loop. Does this lead to my dark LEDs?

The sketch works well, the matrix shows the correct time.
While I'm uploading, some LEDs light up (always other ones). They light up very bright, so the mistake cannot be in the hardware.
I'd be very glad if somebody could show me how to handle the DS1307 module exactly!
max
Code:


/*Wortuhr
 **4AHETE, 9.1.2013
 V1.0

 */

#include <Wire.h>
#include "DS1307.h"
#include "Button.h"
#include "Zahlen.h"
#include "Buchstaben.h"
#include "RTClib.h"
#include "ShiftRegister.h"



#define VOR          matrix[3] |= 0b1110000000000000
#define NACH         matrix[3] |= 0b0000000111100000
#define ESIST        matrix[0] |= 0b1101110000000000
#define UHR          matrix[9] |= 0b0000000011100000

#define FUENF        matrix[0] |= 0b0000000111100000
#define ZEHN         matrix[1] |= 0b1111000000000000
#define VIERTEL      matrix[2] |= 0b0000111111100000
#define ZWANZIG      matrix[1] |= 0b0000111111100000
#define HALB         matrix[4] |= 0b1111000000000000
#define DREIVIERTEL  matrix[2] |= 0b1111111111100000

#define H_EIN        matrix[5] |= 0b1110000000000000
#define H_EINS       matrix[5] |= 0b1111000000000000
#define H_ZWEI       matrix[5] |= 0b0000000111100000
#define H_DREI       matrix[6] |= 0b1111000000000000
#define H_VIER       matrix[6] |= 0b0000000111100000
#define H_FUENF      matrix[4] |= 0b0000000111100000
#define H_SECHS      matrix[7] |= 0b1111100000000000
#define H_SIEBEN     matrix[8] |= 0b1111110000000000
#define H_ACHT       matrix[7] |= 0b0000000111100000
#define H_NEUN       matrix[9] |= 0b0001111000000000
#define H_ZEHN       matrix[9] |= 0b1111000000000000
#define H_ELF        matrix[4] |= 0b0000011100000000
#define H_ZWOELF     matrix[8] |= 0b0000001111100000
#define UPSIDEDOWN 9-
int datapin             =   3;
int output_enable       =   5;
int clock               =   13;
int latch               =   2;
int helpState = 0;

ShiftRegister shiftRegister(3, 13, 2);


Button modePlusButton(7);
Button modeMinusButton(12);



byte linesToWrite = 10;

#define MIN 0
#define NORMAL 1
#define SECONDS 2
#define MINUTES 3
#define HOURS 4
#define SCRAMBLE 5
#define BLANK 6
#define ALL 7
#define MAX 8
int mode = NORMAL;
word matrix[16];

RTC_DS1307 RTC;


void setup()
{

  Wire.begin();
  RTC.begin();
  Serial.begin(57600);
  pinMode(datapin, OUTPUT);
  pinMode(output_enable,OUTPUT);
  pinMode(latch, OUTPUT);
  pinMode(clock, OUTPUT);
  digitalWrite(output_enable, LOW);
  RTC.adjust(DateTime(__DATE__, __TIME__));


}

void loop()

  DateTime now = RTC.now();
  int Stunden = now.hour();
  int Minuten = now.minute();
  int Sekunden = now.second();

  Serial.print(now.year(), DEC);
  Serial.print('/');
  Serial.print(now.month(), DEC);
  Serial.print('/');
  Serial.print(now.day(), DEC);
  Serial.print(' ');
  Serial.print(now.hour(), DEC);
  Serial.print(':');
  Serial.print(now.minute(), DEC);
  Serial.print(':');
  Serial.print(now.second(), DEC);
  Serial.println();
  switch (mode) {

  case NORMAL:
    clearScreenBuffer();
    setWords(Stunden, Minuten);
    setMinutes(Minuten);
    Serial.println(Stunden);
    Serial.println(Minuten);
   case 2:
    matrix[1] |= 0b0000000000010000;
    matrix[0] |= 0b0000000000001000;
    break;
  case 3:
    matrix[1] |= 0b0000000000010000;
    matrix[0] |= 0b0000000000001000;
    matrix[3] |= 0b0000000000000100;
    break;
  case 4:
    matrix[1] |= 0b0000000000010000;
    matrix[0] |= 0b0000000000001000;
    matrix[3] |= 0b0000000000000100;
    matrix[2] |= 0b0000000000000010;
    break;
  }
}

void setWords(int hours, int minutes) {
  while (hours > 12) {
    hours -= 12;
  }

  ESIST;

  switch (minutes / 5) {
  case 0:
    // glatte Stunde
    setHours(hours, true);
    break;
  case 1:
    // 5 nach
    FUENF;
    NACH;
    setHours(hours, false);
    break;
  case 2:
    // 10 nach
    ZEHN;
    NACH;
    setHours(hours, false);
    break;
  case 3:
    // viertel
    VIERTEL;
    setHours(hours + 1, false);
    break;
  case 4:
    // 20 nach
    ZWANZIG;
    NACH;
    setHours(hours, false);
    break;
  case 5:
    // 5 vor halb
    FUENF;
    VOR;
    HALB;
    setHours(hours + 1, false);
    break;
  case 6:
    // halb
    HALB;
    setHours(hours + 1, false);
    break;
  case 7:
    // 5 nach halb
    FUENF;
    NACH;
    HALB;
    setHours(hours + 1, false);
    break;
  case 8:
    // 20 vor
    ZWANZIG;
    VOR;
    setHours(hours + 1, false);
    break;
  case 9:
    // dreiviertel
    DREIVIERTEL;
    setHours(hours + 1, false);
    break;
  case 10:
    // 10 vor
    ZEHN;
    VOR;
    setHours(hours + 1, false);
    break;
  case 11:
    // 5 vor
    FUENF;
    VOR;
    setHours(hours + 1, false);
    break;
  }
}

void setHours(int hours, boolean glatt)
{
  while (hours > 12)
  {
    hours -= 12;
  }

  if (glatt)
  {
    UHR;
  }

  switch (hours)
  {
  case 0:
  case 12:
  case 24:
    H_ZWOELF;
    break;
  case 1:
  case 13:
    if (glatt)
    {
      H_EIN;
    } 
    else
    {
      H_EINS;
    }
    break;
  case 2:
  case 14:
    H_ZWEI;
    break;
  case 3:
  case 15:
    H_DREI;
    break;
  case 4:
  case 16:
    H_VIER;
    break;
  case 5:
  case 17:
    H_FUENF;
    break;
  case 6:
  case 18:
    H_SECHS;
    break;
  case 7:
  case 19:
    H_SIEBEN;
    break;
  case 8:
  case 20:
    H_ACHT;
    break;
  case 9:
  case 21:
    H_NEUN;
    break;
  case 10:
  case 22:
    H_ZEHN;
    break;
  case 11:
  case 23:
    H_ELF;
    break;
  }
}


void scrambleScreenBuffer()
{
  for (int i = 0; i < 16; i++)
  {
    matrix[i] = random(65536);
  }
}


void clearScreenBuffer()
{
  for (int i = 0; i < 16; i++)
  {
    matrix[i] = 0;
  }
}


void setAllScreenBuffer()
{
  for (int i = 0; i < 16; i++)
  {
    matrix[i] = 65535;
  }
}


void writeMatrix()
{

  word row = 1;

  for (int k = 0; k < linesToWrite; k++)
  { 

    shiftRegister.prepareShiftregisterWrite();
    shiftRegister.shiftOut(~matrix[UPSIDEDOWN k]);
    shiftRegister.shiftOut(row);
    shiftRegister.finishShiftregisterWrite();
    row = row << 1;
  }



}


Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 53
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Does anybody have an idea??
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 513
Posts: 26247
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hard to say what is supposed to be happening with this totally uncommented code.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Pages: [1]   Go Up
Jump to: