#define BUTTON_SELECT_MOD 2
#define BUTTON_SPEED_NEXT 3
#define BUTTON_SPEED_BACK 4
#define MAX_SPEED_BLINK 10
#define MODE_AUDIO 0
#define MODE_BLINK 1
bool BUTTON_SELECT_MOD_PRESSED = false;
long int TIME_BUTTON = 0;
//VHODNÉ ULOŽIT DO EEPROM
int SELECT_MODE = MODE_AUDIO;
int SPEED_BLINK = 0;
//______________________
void setup() {
pinMode(BUTTON_SELECT_MOD, INPUT);
pinMode(BUTTON_SPEED_NEXT, INPUT);
pinMode(BUTTON_SPEED_BACK, INPUT);
}
void loop() {
//___________PŘEPÍNÁNÍ AUDIO A BLIKÁNÍ_________[VYUŽITÍ I PRO ON/OFF]
if (digitalRead(BUTTON_SELECT_MOD) == HIGH) {
if (BUTTON_SELECT_MOD_PRESSED == false) {
BUTTON_SELECT_MOD_PRESSED = true;
if (SELECT_MODE == MODE_AUDIO) {
SELECT_MODE = MODE_BLINK;
} else {
SELECT_MODE = MODE_AUDIO;
}
}
} else {
BUTTON_SELECT_MOD_PRESSED = false;
}
//____________________________________________
if (SELECT_MODE == MODE_AUDIO) {
// KÓD KDYŽ JE AUDIO
} else if (SELECT_MODE == MODE_BLINK) {
//___________NASTAVENÍ RYCHLOSTI_________
if (digitalRead(BUTTON_SPEED_NEXT) == HIGH or digitalRead(BUTTON_SPEED_BACK) == HIGH) {
if (millis() >= TIME_BUTTON + 1000) {
TIME_BUTTON = millis();
if (digitalRead(BUTTON_SPEED_NEXT) == HIGH and SPEED_BLINK <= MAX_SPEED_BLINK) SPEED_BLINK++;
if (digitalRead(BUTTON_SPEED_BACK) == HIGH and SPEED_BLINK >= 0) SPEED_BLINK--;
}
} else {
TIME_BUTTON = millis() - 1000;
}
//_____________________________________
}
}