Herunterladen Diese Seite drucken

AZ-Delivery Dice Duo Matrix Anleitung Zur Montage Seite 6

Werbung

Verfügbare Sprachen

Verfügbare Sprachen

}
}
// Wait for a random short time
delay(random(50, 200));
}
// Clear both displays
for
(int
device = 0; device < 2; device++) {
lc.clearDisplay(device);
}
}
void
loop() {
// Read the state of the switch into a local variable
int
reading = digitalRead(buttonPin);
// Check if the reading is different from the last reading
if
(reading != lastButtonState) {
// Reset the debouncing timer
lastDebounceTime = millis();
}
// If the reading has been stable for longer than the debounce delay,
take it as the actual state
if
((millis() - lastDebounceTime) > debounceDelay) {
// If the button state has changed
if
(reading != buttonState) {
buttonState = reading;
// Only act when the button is pressed (LOW because of
INPUT_PULLUP)
if
(buttonState == LOW) {
animate();
pressed
// Generate random numbers for each die
int
diceValues[2];
for
(int
i = 0; i < 2; i++) {
diceValues[i] = random(1, 7);
}
// Display die faces on each device
for
(int
i = 0; i < 2; i++) {
displayDieFace(dice[diceValues[i] - 1], i);
}
// Show animation on both devices when button is
// Random number between 1 and 6
6

Werbung

loading

Verwandte Produkte für AZ-Delivery Dice Duo Matrix