Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.00 KB | None | 0 0
  1. // EŠTE #include knižnice pre MATRIX displej
  2.  
  3. const int buttonPin1 = 5;
  4. int buttonState1 = HIGH;
  5. int lastButtonState1 = HIGH;
  6. unsigned long lastDebounceTime1 = 0;
  7. unsigned long debounceInterval = 50;
  8. int cislo = 0;
  9. void setup() {
  10.   pinMode(buttonPin1, INPUT_PULLUP);
  11.   matrix.begin();
  12.   matrix.setTextSize(1);
  13.   matrix.setTextWrap(false);
  14. }
  15. void vykresli_cislo() {
  16.   matrix.setTextColor(matrix.Color333(0, 1, 0));
  17.   matrix.setCursor(13, 5);
  18.   String cislo_ako_text = String(cislo);
  19.   // VYPIS CISLA
  20.   matrix.print(F(cislo_ako_text));
  21. }
  22. void loop() {
  23.   int reading1 = digitalRead(buttonPin1);
  24.   if (reading1 != lastButtonState1) {
  25.     lastDebounceTime1 = millis();
  26.   }
  27.  
  28.   if ((millis() - lastDebounceTime1) > debounceInterval) {
  29.     if (reading1 != buttonState1) {
  30.       buttonState1 = reading1;
  31.       if (buttonState1 == HIGH) {
  32.         cislo++;
  33.         if (cislo > 9) {
  34.           cislo = 0;
  35.         }
  36.         vykresli_cislo();
  37.       }
  38.     }
  39.   }
  40.   lastButtonState1 = reading1;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement