0Pricing
Arduino & IoT Academy · Lekcja

delay() i taktowanie migania

Wstrzymywanie wykonywania, aby uzyskać widoczny rytm migania

delay() i taktowanie migania to bezpłatna lekcja Arduino & IoT Academy na CoddyKit. To lekcja 3 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Arduino & IoT Academy, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Arduino & IoT Academy zawiera 4 lekcji w sumie.

Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.

Add a Pause

Switching a pin on and off happens in microseconds, far too fast to see. To make a real blink, you tell the board to wait with delay. ⏱️

delay Speaks Milliseconds

The delay function pauses your sketch for a number of milliseconds. One second is 1000 of them, so delay(1000) waits one full second.

delay(1000);

Freeze the Light On

Turn the LED HIGH, then call delay. The board sits still and the LED stays lit for the whole pause before doing anything else.

digitalWrite(ledPin, HIGH);
delay(1000);

Then Hold It Off

Now drive the pin LOW and delay again. The LED stays dark for that pause, giving the off half of your blink its own visible moment.

digitalWrite(ledPin, LOW);
delay(1000);

The Full Blink Loop

Stack those four lines inside loop() and you get a steady blink: on, wait, off, wait, repeat. That is the classic Blink sketch.

void loop() {
  digitalWrite(ledPin, HIGH);
  delay(1000);
  digitalWrite(ledPin, LOW);
  delay(1000);
}

Faster or Slower

Change the number to change the rhythm. A smaller value like delay(200) makes a quick flash, while a larger one slows the blink right down.

delay(200);

On and Off Can Differ

The two delays do not have to match. A long on-time and short off-time gives a steady glow with a brief wink between pulses.

delay Stops Everything

Here is the catch: during a delay the board does nothing else. It cannot read a button or sensor, because delay blocks the whole sketch.

Fine for Now

For a simple blink, blocking is fine. Later you will meet millis, a way to time events without freezing the rest of your program.

Tiny vs Big Waits

delay handles milliseconds, but for very short pauses there is delayMicroseconds. You will need it later for precise sensor timing.

Loop Does the Repeating

You never write a repeat command. Because loop() runs again automatically, your on-off-wait pattern repeats forever on its own.

Quick Check

You want the LED to stay on for exactly two seconds.

Recap

You used delay to pace your blink, learned it counts milliseconds, and saw that it blocks everything else. Next you will wire a real LED. 🎉

Często zadawane pytania

Czy lekcja „delay() i taktowanie migania” jest bezpłatna?

Tak — pełny tekst „delay() i taktowanie migania” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Arduino & IoT Academy, przejdź na CoddyKit PRO. Kurs Arduino & IoT Academy zawiera 4 lekcji w sumie.

Co nauczysz się w „delay() i taktowanie migania”?

Wstrzymywanie wykonywania, aby uzyskać widoczny rytm migania Ćwiczysz Arduino & IoT Academy z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.

Czy potrzebuję doświadczenia, aby zacząć Arduino & IoT Academy?

Nie wymagamy żadnego doświadczenia. Arduino & IoT Academy w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 3 z 4.

Ile czasu zajmuje lekcja „delay() i taktowanie migania”?

Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.

Czy mogę pisać i uruchamiać kod w tej lekcji Arduino & IoT Academy?

Tak. Każda lekcja Arduino & IoT Academy zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.

Wszystkie lekcje w tym kursie

  1. pinMode i OUTPUT
  2. digitalWrite HIGH i LOW
  3. delay() i taktowanie migania
  4. Bezpieczne podłączanie zewnętrznej diody LED
← Powrót do Arduino & IoT Academy