This is an old revision of the document!


Rolling text matrix


Autor

Stefanescu Georgiana-Cristina 331CA


Introducere

Am ales ca tema a proiectului realizarea unui sistem care afiseaza text introdus de catre un utilizator pe un ecran de tip matrice cu led-uri.


Descriere generala

Introducerea textului se face in codul care programeaza afisarea textului. Odata pornit proiectul, textul din buffer-ul dat se va afisa pe ecranul-matrice in modalitatea “rolling text”.


Hardware Design

Lista piese:

  • Arduino UNO
  • Matrice cu LED-uri MAX7219
  • Butoane
  • Rezistente
  • Led-uri
  • Breadboard
  • Fire (mama-tata, mama-mama, tata-tata)

Schema bloc


Software Design

Descrierea codului aplicaţiei

  • mediu de dezvoltare Arduino IDE
  • biblioteci
    • #include <SPI.h>
    • #include <Adafruit_GFX.h>
    • #include <Max72xxPanel.h>

#include <SPI.h> #include <Adafruit_GFX.h> #include <Max72xxPanel.h> Vcc - Vcc Gnd - Gnd Din - Mosi (Pin 11) Cs - SS (Pin 10) Clk - Sck (Pin 13) int buttonPin = 2; variable to check if the button is pressed or not int buttonState; helper variable to check if the button is pressed or not int reading; flag to determine on/off for the button boolean onOffFlag = true; last state of the button for debounce alg int lastButtonState = LOW; the last time the output pin was toggled unsigned long lastDebounceTime = 0; the debounce time; increase if the output flickers unsigned long debounceDelay = 50; helper variable to check if the sensor detects movement or not int movementState = LOW; const int pinCS = 10; const int numberOfHorizontalDisplays = 8; const int numberOfVerticalDisplays = 1; Max72xxPanel matrix = Max72xxPanel(pinCS, numberOfHorizontalDisplays, numberOfVerticalDisplays); const int wait = 50; Velocidad a la que realiza el scroll const int spacer = 1; const int width = 5 + spacer; Ancho de la fuente a 5 pixeles void setup(){ Serial.begin(9600); matrix. setIntensity ( 1 ) ; Adjust the brightness between 0 and 15

 matrix. setPosition ( 0 ,  0 ,  0 ) ;  // The first display is at <0, 0>
 matrix. setPosition ( 1 ,  1 ,  0 ) ;  // The second display is at <1, 0>
 matrix. setPosition ( 2 ,  2 ,  0 ) ;  // The third display is in <2, 0>
 matrix. setPosition ( 3 ,  3 ,  0 ) ;  // The fourth display is at <3, 0>
 matrix. setPosition ( 4 ,  4 ,  0 ) ;  // The fifth display is at <4, 0>
 matrix. setPosition ( 5 ,  5 ,  0 ) ;  // The sixth display is at <5, 0>
 matrix. setPosition ( 6 ,  6 ,  0 ) ;  // The seventh display is at <6, 0>
 matrix. setPosition ( 7 ,  7 ,  0 ) ;  // The eighth display is in <7, 0>
 matrix. setPosition ( 8 ,  8 ,  0 ) ;  // The ninth display is at <8, 0>
 matrix. setRotation ( 0 ,  1 ) ;     // Display position
 matrix. setRotation ( 1 ,  1 ) ;     // Display position
 matrix. setRotation ( 2 ,  1 ) ;     // Display position
 matrix. setRotation ( 3 ,  1 ) ;     // Display position
 matrix. setRotation ( 4 ,  1 ) ;     // Display position
 matrix. setRotation ( 5 ,  1 ) ;     // Display position
 matrix. setRotation ( 6 ,  1 ) ;     // Display position
 matrix. setRotation ( 7 ,  1 ) ;     // Display position
 matrix. setRotation ( 8 ,  1 ) ;     // Display position
 pinMode(buttonPin, INPUT_PULLUP);

}

void loop() {

 String string = " Acesta este proiectul meu la PM";
 long int time = millis();
 while(Serial.available() && onOffFlag) {
    string += char(Serial.read());
 }
 for(int i = 0; i < width * string.length() + matrix.width() - 1 - spacer && onOffFlag; i++) {
     
     buttonState = digitalRead(buttonPin);
 // for (int i = 0; i < BUTTONS_NO; i++) {
    /* compare the buttonState to its previous state */
    if (buttonState != lastButtonState) {
      /* if the state has changed, increment the counter */
      if (buttonState == HIGH) {
          /* if the current state is HIGH then the button went from off to on */
          delay(3000);
          onOffFlag = true;
      } else {
          /* if the current state is LOW then the button went from on to off */
          delay(3000);
          onOffFlag = false;
      }
      
      // Delay a little bit to avoid bouncing
      delay(50);
    }
    // save the current state as the last state, for next time through the loop
    lastButtonState = buttonState;
    matrix.fillScreen(LOW);
    int letter = i / width;
    int x = (matrix.width() - 1) - i % width;
    int y = (matrix.height() - 8) / 2; // Centrar el texto
    while(x + width - spacer >= 0 && letter >= 0) {
       if(letter < string.length()){
           matrix.drawChar(x, y, string[letter], HIGH, LOW, 1);
       }
       letter--;
       x -= width;
    }
    matrix.write(); // Muestra loscaracteres
    delay(wait);
 }

}


Rezultate obtinute


Concluzii


Download

Jurnal

  • 27 Aprilie → alegerea temei pentru proiect
  • 1 Mai → realizarea diagramei bloc si a schemei cablaj
  • 15 Mai → comandarea pieselor necesare
  • 28 Mai → cablarea fizica a componentelor
  • 30 Mai → implementarea software
  • 3 Iunie → finalizare proiect

Bibliografie/ Resurse


pm/prj2021/alazar/rolling_text_matrix.1622733950.txt.gz · Last modified: 2021/06/03 18:25 by gstefanescu2304
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0