hum.. who do you think is updating wylacz magically for you in? if (wylacz == LOW) { //if button pushed
also if you don't want to have issues in ~50 days with millis() rolling over, you should write the test using subtraction not addition. Using magical numbers (1, 2, 3) for you alarm state is not great, use an enum it will be more readable.)
enum alarmState_t : byte {ALARM_IDLE, ALARM_ACTIVATED, ALARM_DEACTIVATED} stanAlarmu;
...
time_now = millis();
while (millis() - time_now < period) {
if (digitalRead(myButton) == LOW) { // button pushed, cancel the wait period
stanAlarmu = ALARM_DEACTIVATED;
break;
}
}
...
Last but not least, don't post snippets (Snippets R Us!)
J-M-L:
hum.. who do you think is updating wylacz magically for you in? if (wylacz == LOW) { //if button pushed
Thanks, it's interesting, when I changed it as per your suggestion it works - but why my variable "wylacz" doesn't work
wylacz == LOW
I have definied it as below:
#define rozbrojenie 6
int wylacz;
void setup() {
// put your setup code here, to run once:
pinMode(rozbrojenie, INPUT_PULLUP);
}
void loop() {
// put your main code here, to run repeatedly:
wylacz = digitalRead(rozbrojenie);