This shows you the differences between two versions of the page.
|
pm:prj2021:alazar:rolling_text_matrix [2021/06/03 18:27] gstefanescu2304 |
pm:prj2021:alazar:rolling_text_matrix [2021/06/03 18:31] (current) gstefanescu2304 |
||
|---|---|---|---|
| Line 43: | Line 43: | ||
| * #include <Max72xxPanel.h> | * #include <Max72xxPanel.h> | ||
| - | + | Cod: {{:pm:prj2021:alazar:code_matrix.txt|}} | |
| - | ......... COD ......... | + | |
| - | + | ||
| - | + | ||
| - | #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 === | === Rezultate obtinute === | ||
| + | {{:pm:prj2021:alazar:whatsapp_image_2021-06-03_at_18.25.04_1_.jpeg?nolink&300|}} | ||
| + | {{:pm:prj2021:alazar:whatsapp_image_2021-06-03_at_18.25.04.jpeg?nolink&300|}} | ||
| ---- | ---- | ||
| Line 160: | Line 59: | ||
| * Arhiva proiect: {{:pm:prj2021:alazar:stefanescu_georgiana_331ca.rar|}} | * Arhiva proiect: {{:pm:prj2021:alazar:stefanescu_georgiana_331ca.rar|}} | ||
| * Link video: https://youtu.be/J9NHwsOgtKg | * Link video: https://youtu.be/J9NHwsOgtKg | ||
| + | * Pdf pagina: {{:pm:prj2021:alazar:rolling_text_matrix_cs_open_courseware_.pdf|}} | ||
| ---- | ---- | ||