@emtekpro,
Unfortunately there is no Indonesian section of the forum for you to use. There are various international sections in various languages, you can use whichever one suits your language knowledge. Otherwise please post in English in the English part of the forum, you may use Google translate if you need to.
You may get a clue from the following excerpt and sketch:
1.Working Principle of millis() Function: The millis() function and millisCounter can be used to account for the elapse of 1000 ms ( for example) time period. The millisCounter starts with initial value of 0 (zero) when the uploading process of a sketch is finished in the UNO. After that it is incremented by the elapse of every 1ms time. The execution of millis() function reads the current content of the millisCounter, which says how much ms (millisecond) time has elapsed since the UNO has started. The millisCounter is a 32-bit unsigned counter (composed of four consecutive RAM locations) and can hold 232 ms time (49-day 17-hour 2-minute 47-second 296-millisecond) before overflow occurs. For example: The millis() function can be used in the following ways to observe if 2000 ms (2 sec) has elapsed from the current instant.
unsigned long prMillis = millis(); //present/current content of millisCounter
do
{
; //do nothing or some other task
}
while(millis – prMillis < 2000)!
//prMillis is fixed; millis() gives current time of millisCounter
//which continuously advances by 1 ms.
2. The following sketch uses millis() function to keep L (built0in LED of UNO) ON for 1000 ms and OFF for 5000 ms.
unsigned long prMillis = 0;
byte ledState = HIGH;
bool flag = true;
void setup()
{
Serial.begin(9600);
pinMode(13, OUTPUT);
digitalWrite(13, ledState); //LED is ON
prMillis = millis();
}
void loop()
{
if (flag == true) //ON
{
callDelay(1000);
}
else //OFF
{
callDelay(5000);
}
}
void callDelay(unsigned long interval)
{
if (millis() - prMillis >= interval)//5-sec is over
{
ledState = !ledState;
digitalWrite(13, ledState); //LED toggles
flag = !flag;
prMillis = millis();
}
}