#include "MaxMatrix.h"
int DIN = 3;
int CLK = 5;
int CS = 4;
int BUTTON_PIN = 2;
MaxMatrix m(DIN, CS, CLK, 1);
volatile bool shouldRoll = false;
unsigned long lastPressTime = 0;
char Rzut_1[] = {8, 8, B00000000, B00000000, B00000000, B00011000, B00011000, B00000000, B00000000, B00000000};
char Rzut_2[] = {8, 8, B11000000, B11000000, B00000000, B00000000, B00000000, B00000000, B00000011, B00000011};
char Rzut_3[] = {8, 8, B11000000, B11000000, B00000000, B00011000, B00011000, B00000000, B00000011, B00000011};
char Rzut_4[] = {8, 8, B11000011, B11000011, B00000000, B00000000, B00000000, B00000000, B11000011, B11000011};
char Rzut_5[] = {8, 8, B11000011, B11000011, B00000000, B00011000, B00011000, B00000000, B11000011, B11000011};
char Rzut_6[] = {8, 8, B11011011, B11011011, B00000000, B00000000, B00000000, B00000000, B11011011, B11011011};
void setup() {
m.init();
m.setIntensity(8);
pinMode(BUTTON_PIN, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(BUTTON_PIN), onButtonPress, FALLING);
}
void loop() {
if (shouldRoll) {
shouldRoll = false;
int liczba_oczek = random(1, 7);
m.clear();
switch (liczba_oczek) {
case 1: m.writeSprite(0, 0, Rzut_1); break;
case 2: m.writeSprite(0, 0, Rzut_2); break;
case 3: m.writeSprite(0, 0, Rzut_3); break;
case 4: m.writeSprite(0, 0, Rzut_4); break;
case 5: m.writeSprite(0, 0, Rzut_5); break;
case 6: m.writeSprite(0, 0, Rzut_6); break;
}
delay(1000);
}
}
void onButtonPress() {
unsigned long now = millis();
if (now - lastPressTime > 200) {
shouldRoll = true;
lastPressTime = now;
}
}
nano:12
nano:11
nano:10
nano:9
nano:8
nano:7
nano:6
nano:5
nano:4
nano:3
nano:2
nano:GND.2
nano:RESET.2
nano:0
nano:1
nano:13
nano:3.3V
nano:AREF
nano:A0
nano:A1
nano:A2
nano:A3
nano:A4
nano:A5
nano:A6
nano:A7
nano:5V
nano:RESET
nano:GND.1
nano:VIN
nano:12.2
nano:5V.2
nano:13.2
nano:11.2
nano:RESET.3
nano:GND.3
matrix1:V+
matrix1:GND
matrix1:DIN
matrix1:CS
matrix1:CLK
matrix1:V+.2
matrix1:GND.2
matrix1:DOUT
matrix1:CS.2
matrix1:CLK.2
btn1:1.l
btn1:2.l
btn1:1.r
btn1:2.r
r1:1
r1:2