projekte:arduino_projekte:matrix_display
Dies ist eine alte Version des Dokuments!
Inhaltsverzeichnis
Matrix Display Uhr
Übersicht
Ich wollte schon immer eine LED Matrix Uhr haben, daher habe ich mir nun endlich eine gebaut. So nebenbei, der Start der Uhr kann manchmal eine Minute dauern.
Material
- DS1307 RTC Uhr, Marco hat gerade einen ganzen Schwung davon (25.10.2015)
- Arduino Pro Micro, damit alles klein bleibt
- MAX7219 Matrix
Librarys
Pin Verbindungen
Wichtig zu wissen, SDA muss an SDA, SCL an SCL, also nicht zu verwechseln mit dem UART (TX an RX, RX an TX)
Die DS1307 MUSS mit 5V betrieben werden.
Der DS Pin (SQW) wird in meinem Fall nicht genutzt, weil der Arduino einen eigenen Quartz hat.
Arduino Pin | RTC Uhr pin | Matrix Pin |
---|---|---|
2 | SDA | |
3 | SCL | |
15 | CLK | |
14 | N.C | |
16 | DIN | |
10 | CS |
Die Uhr Synchronisieren
Unter Beispiele → DS1307RTC → SetTime ist ein Zeitsynchronisierungsprogramm vorhanden, es muss einfach nur geflashed werden, die RTC Uhr wird dann mit der Compiler Zeit Synchronisiert (Zeit des Flashens)
Der Code
- matrixclock2.ino
/* * MatrixDisplayClock2 * example code illustrating Time library with Real Time Clock and Matrix7219 display. * */ //Matrix #include <SPI.h> #include <Adafruit_GFX.h> #include <Max72xxPanel.h> int pinCS = 10; // Attach CS to this pin, DIN to MOSI and CLK to SCK (cf http://arduino.cc/en/Reference/SPI ) int numberOfHorizontalDisplays = 4; int numberOfVerticalDisplays = 1; Max72xxPanel matrix = Max72xxPanel(pinCS, numberOfHorizontalDisplays, numberOfVerticalDisplays); //RTC Clock #include <Time.h> #include <Wire.h> #include <DS1307RTC.h> // a basic DS1307 library that returns time as a time_t void setup() { setSyncProvider(RTC.get); // the function to get the time from the RTC matrix.setIntensity(1); // Use a value between 0 and 15 for brightness //Define order of matrix elements (display, x , y) matrix.setPosition(0, 0, 0); matrix.setPosition(1, 1, 0); matrix.setPosition(2, 2, 0); matrix.setPosition(3, 3, 0); //Rotate matrix @ 90 degress //0, 90, 180, 270 matrix.setRotation(0, 1); matrix.setRotation(1, 1); matrix.setRotation(2, 1); matrix.setRotation(3, 1); } void loop() { if (timeStatus() == timeSet) { //If times is set, display time digitalClockDisplay(); } else { //Time ist not set in this case, display ERR! as error message; matrix.fillScreen(LOW); matrix.setCursor(1, 1); matrix.print("ERR!"); delay(4000); } delay(1000); } void digitalClockDisplay(){ //Matrix //Clear matrix matrix.fillScreen(LOW); //Hour matrix.setCursor(1, 1); matrix.print(hour()); //Symbol matrix.setCursor(13,1); matrix.print(":"); matrix.setCursor(14,1); matrix.print(":"); //minute matrix.setCursor(19,1); if(minute() == 0) { matrix.print("00"); } else if(10 > minute() > 0 ) { matrix.setCursor(19,1); matrix.print("0"); matrix.setCursor(26,1); matrix.print(minute()); } else { matrix.print(minute()); } matrix.write(); // Send bitmap to display }
projekte/arduino_projekte/matrix_display.1484658009.txt.gz · Zuletzt geändert: 2022-11-17 22:34 (Externe Bearbeitung)