jurs:
Die meisten Noobs hier im Forum, die irgendwas mit einer Echtzeituhr machen, fangen ja üblicherweise nicht an, die RTC auf die effizienteste Art selbst zu programmieren, sondern die installieren sich standardmäßige erstmal eine fette RTC-Library und dazu noch eine fette Time-Library, und wenn dann noch Serial für Debug-Ausgaben dazukommen, sind die 2048 Bytes RAM eines UNO bald mehr als überverbraucht und dann dreht der Sketch eben durch.
Danke für den Hinweis. Ich habe vorhin gerade den Mega angeschlossen und alle Kabel 1zu1 getauscht. Hier blinkt die LED-Matrix nicht einmal...
HotSystems:
Und nur zur Info vorab, die von dir gewählte RTC ist sehr ungenau, nimm dazu lieber die DS3231.
Kannst du "ungenau" beziffern? Ich brauche für meine Uhr ein einfaches Sekundensignal, mehr nicht.
HotSystems:
Wie bitte sollen wir das machen, wenn wir deinen Sketch nicht kennen.
Hier mein Sketch. Es sind halt ein paar Spielereien drin, weil ich das Zeitsignal nicht hatte. Unter anderem sind dies zwei Buttons mit denen ich die Stunden und Minuten hochzählen kann. Die RTC Funktionen sind auskommentiert, da so die Matrix funktioniert.
Hier auch noch das Ergebnis vom Kompilieren:
Sketch uses 11,558 bytes (35%) of program storage space. Maximum is 32,256 bytes.
Global variables use 335 bytes (16%) of dynamic memory, leaving 1,713 bytes for local variables. Maximum is 2,048 bytes.
Sketch:
#include <virtuabotixRTC.h>
#include <Adafruit_GFX.h> // Core graphics library
#include <RGBmatrixPanel.h> // Hardware-specific library
#include <avr/pgmspace.h>
// myRTC(clock, data, rst)
//virtuabotixRTC myRTC(11, 12, 13);
//time
int hour_val=10;
int min_val=5;
int sec_val=0;
//
//Switch hour, minute
int switchHour=0;
int switchMin=0;
//Button
int buttonStateHour = 0;
int buttonPinHour = 18;
int lastButtonStateHour = 0;
int buttonStateMin = 0;
int buttonPinMin = 19;
int lastButtonStateMin = 0;
#define CLK 8
#define OE 9
#define LAT 10
#define A A0
#define B A1
#define C A2
#define D A3
RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, false);
//Color
int c_1 = 0;
int c_2 = 7;
int c_3 = 0;
//--------------------------------------------SETUP--------------------------------
void setup()
{
// Initialize the LED matrix
matrix.begin();
// initialize the button pin as a input:
pinMode(buttonPinHour, OUTPUT);
pinMode(buttonPinMin, OUTPUT);
// Setup Serial connection
Serial.begin(9600);
//Set Time
//myRTC.setDS1302Time(00, 58, 23, 2, 17, 11, 2014);
}
void es_isch()
{
matrix.fillRect(1, 1, 18, 3, matrix.Color333(c_1, c_2, c_3));
}
void fuef()
{
//FÜF
matrix.fillRect(22, 1, 9, 3, matrix.Color333(c_1, c_2, c_3));
}
void viertu()
{
//VIERTU
matrix.fillRect(1, 4, 18, 3, matrix.Color333(c_1, c_2, c_3));
}
void zaeae()
{
//ZÄÄ
matrix.fillRect(22, 4, 9, 3, matrix.Color333(c_1, c_2, c_3));
}
void zwaenzg()
{
//ZWÄNZG
matrix.fillRect(1, 7, 18, 3, matrix.Color333(c_1, c_2, c_3));
}
void vor()
{
//VOR
matrix.fillRect(22, 7, 9, 3, matrix.Color333(c_1, c_2, c_3));
}
void ab()
{
//AB
matrix.fillRect(1, 10, 6, 3, matrix.Color333(c_1, c_2, c_3));
}
void haubi()
{
//HAUBI
matrix.fillRect(10, 10, 15, 3, matrix.Color333(c_1, c_2, c_3));
}
void eis()
{
//EIS
matrix.fillRect(1, 13, 9, 3, matrix.Color333(c_1, c_2, c_3));
}
void zwoei()
{
//ZWÖI
matrix.fillRect(10, 13, 12, 3, matrix.Color333(c_1, c_2, c_3));
}
void drue()
{
//DRÜ
matrix.fillRect(22, 13, 9, 3, matrix.Color333(c_1, c_2, c_3));
}
void vieri()
{
//VIERI
matrix.fillRect(1, 16, 15, 3, matrix.Color333(c_1, c_2, c_3));
}
void fuefi()
{
//FÜFI
matrix.fillRect(16, 16, 12, 3, matrix.Color333(c_1, c_2, c_3));
}
void saechsi()
{
//SÄCHSI
matrix.fillRect(1, 19, 18, 3, matrix.Color333(c_1, c_2, c_3));
}
void sibni()
{
//SIBNI
matrix.fillRect(16, 22, 15, 3, matrix.Color333(c_1, c_2, c_3));
}
void achti()
{
//ACHTI
matrix.fillRect(1, 22, 15, 3, matrix.Color333(c_1, c_2, c_3));
}
void nueni()
{
//NÜNI
matrix.fillRect(19, 19, 12, 3, matrix.Color333(c_1, c_2, c_3));
}
void zaeni()
{
//ZÄNI
matrix.fillRect(1, 25, 12, 3, matrix.Color333(c_1, c_2, c_3));
}
void eufi()
{
//EUFI
matrix.fillRect(19, 25, 12, 3, matrix.Color333(c_1, c_2, c_3));
}
void zwoeufi()
{
//ZWÖUIFI
matrix.fillRect(1, 28, 18, 3, matrix.Color333(c_1, c_2, c_3));
}
void screen_black()
{
matrix.fillScreen(0);
}
//--------------------------------------------LOOP-------------------------------
void loop()
{
//Random color
c_1 = random(7);
c_2 = random(7);
c_3 = random(7);
//Update Time
//myRTC.updateTime();
//60 Sekunden
if (sec_val>=60)
{
++min_val;
sec_val=0;
}
//60 Minuten
if (min_val>=60)
{
++hour_val;
min_val=0;
}
//24 Hours
if (hour_val >12)
{
hour_val = hour_val-12;
}
//Switch hour
if (min_val==24)
{
switchHour=0;
}
if (min_val==25 && switchHour == 0)
{
hour_val = hour_val+1;
switchHour=1;
}
//Reset screen
if (min_val%5!=0)
{
switchMin=0;
}
if (min_val%5==0 && switchMin==0)
{
screen_black();
switchMin=1;
}
//Es isch
es_isch();
//Minuten
if (min_val >=5 && min_val <10)
{
fuef();
ab();
}
else if (min_val >=10 && min_val <15)
{
zaeae();
ab();
}
else if (min_val >=15 && min_val <20)
{
viertu();
ab();
}
else if (min_val >=20 && min_val <25)
{
zwaenzg();
ab();
}
else if (min_val >=25 && min_val <30)
{
fuef();
vor();
haubi();
}
else if (min_val >=30 && min_val <35)
{
haubi();
}
else if (min_val >=35 && min_val <40)
{
fuef();
ab();
haubi();
}
else if (min_val >=40 && min_val <45)
{
zwaenzg();
vor();
}
else if (min_val >=45 && min_val <50)
{
viertu();
vor();
}
else if (min_val >=50 && min_val <55)
{
zaeae();
vor();
}
else if (min_val >=55 && min_val <=59)
{
fuef();
vor();
}
//Stunden
if (hour_val == 1)
{
eis();
}
else if (hour_val == 2)
{
zwoei();
}
else if (hour_val == 3)
{
drue();
}
else if (hour_val == 4)
{
vieri();
}
else if (hour_val == 5)
{
fuefi();
}
else if (hour_val == 6)
{
saechsi();
}
else if (hour_val == 7)
{
sibni();
}
else if (hour_val == 8)
{
achti();
}
else if (hour_val == 9)
{
nueni();
}
else if (hour_val == 10)
{
zaeni();
}
else if (hour_val == 11)
{
eufi();
}
else if (hour_val == 12 || hour_val == 0)
{
zwoeufi();
}
//Button Min
buttonStateMin = digitalRead(buttonPinMin);
if (buttonStateMin != lastButtonStateMin)
{
if (buttonStateMin == HIGH)
{
++min_val;
}
}
lastButtonStateMin = buttonStateMin;
//Button Hour
buttonStateHour = digitalRead(buttonPinHour);
if (buttonStateHour != lastButtonStateHour)
{
if (buttonStateHour == HIGH)
{
++hour_val;
screen_black();
}
}
lastButtonStateHour = buttonStateHour;
++min_val;
delay(1000);
}