Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // EŠTE #include knižnice pre MATRIX displej
- const int buttonPin1 = 5;
- int buttonState1 = HIGH;
- int lastButtonState1 = HIGH;
- unsigned long lastDebounceTime1 = 0;
- unsigned long debounceInterval = 50;
- int cislo = 0;
- void setup() {
- pinMode(buttonPin1, INPUT_PULLUP);
- matrix.begin();
- matrix.setTextSize(1);
- matrix.setTextWrap(false);
- }
- void vykresli_cislo() {
- matrix.setTextColor(matrix.Color333(0, 1, 0));
- matrix.setCursor(13, 5);
- String cislo_ako_text = String(cislo);
- // VYPIS CISLA
- matrix.print(F(cislo_ako_text));
- }
- void loop() {
- int reading1 = digitalRead(buttonPin1);
- if (reading1 != lastButtonState1) {
- lastDebounceTime1 = millis();
- }
- if ((millis() - lastDebounceTime1) > debounceInterval) {
- if (reading1 != buttonState1) {
- buttonState1 = reading1;
- if (buttonState1 == HIGH) {
- cislo++;
- if (cislo > 9) {
- cislo = 0;
- }
- vykresli_cislo();
- }
- }
- }
- lastButtonState1 = reading1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement