Millis problem

Can anybody tell me why the loop stops when millis starts?
Thanks in advance!

#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
int msg[1];
RF24 radio(9,10);
const uint64_t pipe = 0xE8E8F0F0E1LL;

int SW1 = 2;
int SW2 = 7;
int SW3 = 4;
int SW4 = 8;
int led = 5;
int przycisk = 3;
unsigned long czas_teraz;
unsigned long czas_start = 0;
unsigned long czas_zwloka = 500;
void setup()
{
pinMode(led, OUTPUT);
pinMode(przycisk, INPUT); 
pinMode(7, INPUT);
digitalWrite(7,HIGH);
pinMode(2, INPUT);
digitalWrite(2,HIGH);
pinMode(4, INPUT);
digitalWrite(4,HIGH);
pinMode(8, INPUT);
digitalWrite(8,HIGH);


Serial.begin(9600);
Serial.println("test SW");

radio.begin();
radio.setDataRate(RF24_250KBPS); 
radio.setPALevel(RF24_PA_MAX);
radio.setChannel(108); 
radio.openWritingPipe(pipe);
}

void loop()
{
if (digitalRead(przycisk) == HIGH)
{
Serial.println("TIME"); 
digitalWrite(led, HIGH); 
czas_start = millis();
}
else 
{
czas_teraz = millis();
if (czas_teraz - czas_start > czas_zwloka && digitalRead(led) == HIGH)
{
digitalWrite(led, LOW); 
czas_start = czas_teraz;
}


if (digitalRead(SW1) == LOW && digitalRead(led) == HIGH ) 
{
Serial.println("SW1");
msg[0] = 101;
radio.write(msg, 1);
}

if (digitalRead(SW2) == LOW && digitalRead(led) == HIGH )
{
Serial.println("SW2");
msg[0] = 102;
radio.write(msg, 2);
}


if (digitalRead(SW3) == LOW && digitalRead(led) == HIGH )
{
Serial.println("SW3");
msg[0] = 103;
radio.write(msg, 1);
}


if (digitalRead(SW4) == LOW && digitalRead(led) == HIGH )
{
Serial.println("SW4");
msg[0] = 104;
radio.write(msg, 4);
}
}
}

kazekwynalazek:
when millis starts?

No, because millis starts when the Arduino starts and never stops, so not sure what you mean.

Can anybody tell me why the loop stops when millis starts?

Your question does not make sense because millis() starts when the Arduino is powered up or is reset.

What problems are you seeing ?

Simply speaking when i turn on LED i want to make whole loop with SW1-SW4 to run for 5 seconds.

And what happens now? What do your serial printouts show you?

I bet there are a lot of "TIME" lines. :wink:

kazekwynalazek:
Simply speaking when i turn on LED i want to make whole loop with SW1-SW4 to run for 5 seconds.

czas_zwloka = 500; is a little bit on the low side if you want it to run for 5 seconds.