Why not blink if i delete this

hi, i am newbies here,
what is this funtion from the all code below of this code, why cant just remove it

thanks

#unsigned long waktusekarang = millis ();
#if (waktusekarang - waktusebelum >= jeda) {
#waktusebelum = waktusekarang;

#const int ledpin = 9;
#unsigned long waktusebelum = 0;
#unsigned long jeda = 1000;
#void setup () {
#pinMode (ledpin, OUTPUT);
#}
#void loop () {
#unsigned long waktusekarang = millis ();
#if (waktusekarang - waktusebelum >= jeda) {
#waktusebelum = waktusekarang;
#if (blinka == LOW) {
#blinka = HIGH;
#}
#else { (blinka = LOW);
#}
#digitalWrite (ledpin, blinka);
#}
#}

Because that's the timing code.

Please remember to use code tags when posting code

1 Like

sorry asking again.. how the timing code work... i still not get it, how it work as timing with this code

#if (blinka == LOW) {
#blinka = HIGH;
#}
#else { (blinka = LOW);
#}

related with this code

#unsigned long waktusekarang = millis ();
#if (waktusekarang - waktusebelum >= jeda) {
#waktusebelum = waktusekarang;

This

if (blinka == LOW) {
blinka = HIGH;
}
else { (blinka = LOW);
}

Simply toggles the variable "blinka" between the values HIGH and LOW (or on and off, though which is which depends on how the LED is wired to the output pin).

If you didn't slow this down, the loop function would cause the LED to be switched on and off so quickly that to the eye, it would just seem to be slightly dimmer than normal.

So,the condition waits until a certain number of milliseconds (in your case 1000, or one second) have passed before toggling the variable

Rinse and repeat

1 Like

sorry asking again

how is ,

#waktusekarang
#waktusebelum
#jeda

as timer for the code above... i cant understand since i cant found it related..
is it, the arduino reading the # waktusekarang, #waktusebelum and #jeda first before continue the on and off code.. sorry asking much, its my 4th day learning arduino

Look at the clock.
Write down the number of seconds since midnight. Call that value A

Label:
Look at the clock and write down the number of seconds since midnight. Call that value B.
Subtract A from B. If that value is greater than or equal to 1000:, do the following
1)Toggle the LED.
2)Assign the value of variable B to variable A.

Goto Label.

Now, speed that all up to microprocessor speeds.

Do you recognise those steps in the code you posted?

1 Like

thanks very much.. i got and understand now..