Advertisement
Gudu0

Led Matrix and Lcd display.

May 10th, 2025
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.18 KB | None | 0 0
  1. #include <LiquidCrystal.h>
  2. #include <LedControl.h>
  3. //www.elegoo.com
  4. //2016.12.9
  5.  
  6. /*
  7.   The circuit for lcd:
  8.  * LCD RS pin to digital pin 7
  9.  * LCD Enable pin to digital pin 8
  10.  * LCD D4 pin to digital pin 9
  11.  * LCD D5 pin to digital pin 10
  12.  * LCD D6 pin to digital pin 11
  13.  * LCD D7 pin to digital pin 12
  14.  * LCD R/W pin to ground
  15.  * LCD VSS pin to ground
  16.  * LCD VCC pin to 5V
  17.  * 10K resistor:
  18.  * ends to +5V and ground
  19.  * wiper to LCD VO pin (pin 3)
  20.  
  21. The circuit for led matrix:
  22.  pin 6 is connected to the DataIn
  23.  pin 5 is connected to LOAD(CS)
  24.  pin 4 is connected to the CLK
  25.  */
  26.  
  27. LedControl lc=LedControl(6,4,5,1);
  28.  
  29. /* image switching time */
  30. unsigned long delaytime1=500;
  31. unsigned long delaytime2=50;
  32.  
  33. // include the library code:
  34.  
  35.  
  36. // initialize the library with the numbers of the interface pins
  37. LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
  38.  
  39. void setup() {
  40.   // set up the LCD's number of columns and rows:
  41.   lcd.begin(16, 2);
  42.  
  43.   //Matrix
  44.   lc.shutdown(0,false);
  45.   /* Set the brightness to a medium values */
  46.   lc.setIntensity(0,0);
  47.   /* and clear the display */
  48.   lc.clearDisplay(0);
  49. }
  50.  
  51.  
  52. void writeArduinoOnMatrix() {
  53.   /* here is the data for the characters */
  54. /* new by me */
  55. byte SMI[] = {B00000000,
  56.               B01100110,
  57.               B01100110,
  58.               B00000000,
  59.               B01000010,
  60.               B01100110,
  61.               B00111100,
  62.               B00000000};
  63.  
  64.   displayCharacter(SMI);
  65.   //clearMatrix();
  66. }
  67.  
  68.  
  69.  
  70. void loop() {
  71.   delay(2000);
  72.   clearMatrix();
  73.   // set the cursor to column 0, line 1
  74.   // (note: line 1 is the second row, since counting begins with 0):
  75.   lcd.setCursor(0, 0);
  76.   //lcd.print("I love you!");
  77.   writeArduinoOnMatrix();
  78.   lcd.print("THANK YOU!");
  79.   lcd.setCursor(0, 1);
  80.   lcd.print("                 ");
  81.   delay(2000);
  82.   clearMatrix();
  83.   lcd.setCursor(0, 0);
  84.   lcd.print("Gracious  ");
  85.   delay(500);
  86.   lcd.setCursor(0, 1);
  87.   lcd.print("Professionalism");
  88. }
  89.  
  90. void displayCharacter(byte* Selected) {
  91.   for (int i = 0; i < 8; i++) {
  92.     lc.setRow(0,i,Selected[i]);
  93.   }
  94.   //delay(delaytime1);
  95. }
  96.  
  97. void clearMatrix(){
  98.   for (int i = 0; i < 8; i++) {
  99.     lc.setRow(0,i,0);
  100.   }
  101.   //delay(delaytime1);
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement