Advertisement
microrobotics

Arduino Panel Driver Shield, HUB75 Port

May 10th, 2023
1,185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. To utilize the 16x32 RGB LED Panel Driver Shield with an RTC chip on your Arduino Uno, you'll need to install two libraries: Adafruit's RGBMatrixPanel Library to drive the LED Panel, and the DS1307RTC Library to handle the RTC (Real Time Clock) chip.
  3.  
  4. First, make sure these two libraries are installed in your Arduino IDE. You can install them through the Library Manager or from their respective GitHub repositories.
  5.  
  6. This code initializes the RGB LED panel and the RTC. It then uses the fillScreen function to clear the screen, setCursor to move the cursor to a certain position, setTextColor to set the color of the text, and print to print the current time on the screen. The Color333 function is used to generate a color from the RGB components (each component ranges from 0 to 7).
  7.  
  8. Please replace the pin constants at the beginning of the code with the actual pins you're using to connect the Arduino to the RGB LED panel. The last parameter in the RGBmatrixPanel constructor is for specifying whether the matrix is 32 pixels tall (if true, the matrix is 32 pixels tall, if false, it's 16 pixels tall).
  9.  
  10. Please note that driving an RGB LED panel and managing an RTC chip requires a lot of resources and might not work well on lower-end Arduino boards. Also, the actual behavior might depend on the specific LED panel and RTC chip you're using, so you might need to adjust the code accordingly.
  11.  
  12. Here's a simple example sketch:
  13. */
  14.  
  15. #include <RGBmatrixPanel.h>
  16. #include <Wire.h>
  17. #include <DS1307RTC.h>
  18.  
  19. #define CLK 8
  20. #define LAT A3
  21. #define OE  9
  22. #define A   A0
  23. #define B   A1
  24. #define C   A2
  25.  
  26. RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false);
  27.  
  28. void setup() {
  29.   matrix.begin();
  30.   setSyncProvider(RTC.get);   // the function to get the time from the RTC
  31.   if (timeStatus() != timeSet) {
  32.     Serial.println("Unable to sync with the RTC");
  33.   } else {
  34.     Serial.println("RTC has set the system time");
  35.   }
  36. }
  37.  
  38. void loop() {
  39.   matrix.fillScreen(matrix.Color333(0, 0, 0));
  40.  
  41.   matrix.setCursor(1, 0);
  42.   matrix.setTextColor(matrix.Color333(7, 0, 0)); // Red text
  43.   matrix.print(hour());
  44.   matrix.print(":");
  45.  
  46.   matrix.setTextColor(matrix.Color333(0, 7, 0)); // Green text
  47.   matrix.print(minute());
  48.   matrix.print(":");
  49.  
  50.   matrix.setTextColor(matrix.Color333(0, 0, 7)); // Blue text
  51.   matrix.print(second());
  52.  
  53.   delay(1000);
  54. }
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement