0Pricing
Arduino & IoT Academy · Lekcja

Ustawianie progu jasności

Określać, kiedy jest „wystarczająco ciemno”, aby zareagować na odczyt.

Ustawianie progu jasności 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.

Raw Numbers Need Meaning

An analog reading like 312 means nothing on its own. A threshold turns that number into a clear decision: dark or bright.

What a Threshold Is

A threshold is a cutoff value. Readings on one side count as dark, and readings on the other count as bright.

Store It in a Variable

Keep your cutoff in a named variable so it is easy to find and adjust later in one place.

int threshold = 400;

Compare With if

Use an if statement to compare the live reading against your threshold and branch your logic from there.

if (light < threshold) {
  // it is dark
}

Direction Depends on Wiring

Whether dark means a higher or lower number depends on how you wired the divider. Confirm it before you trust the test.

Find Your Number

Print readings in a bright room and a dark one, then pick a midpoint between them as your starting threshold.

Add else for Bright

Pair your if with an else so the bright case is handled too, instead of doing nothing when light is high.

else {
  // it is bright
}

One Cutoff Causes Flicker

Near the line, tiny changes can flip the result back and forth. This rapid flicker looks like a glitch.

Add Hysteresis

Hysteresis uses two cutoffs: one to switch on and a different one to switch off. The gap stops nervous flicker.

Make It Adjustable

Feed the threshold from a potentiometer so anyone can dial in dark without re-uploading code.

Thresholds Drive Decisions

This same threshold idea works for temperature, moisture, and distance. It is how sensors become decisions.

Quick Check

What problem does hysteresis solve at a light threshold?

Recap: Deciding on Light

You stored a threshold, compared readings with if and else, and added hysteresis so the decision stays steady.

Często zadawane pytania

Czy lekcja „Ustawianie progu jasności” jest bezpłatna?

Tak — pełny tekst „Ustawianie progu jasności” 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 „Ustawianie progu jasności”?

Określać, kiedy jest „wystarczająco ciemno”, aby zareagować na odczyt. Ć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 „Ustawianie progu jasności”?

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. Odczytywanie czujnika ruchu PIR
  2. Pomiar światła za pomocą LDR
  3. Ustawianie progu jasności
  4. Automatyczna lampka nocna
← Powrót do Arduino & IoT Academy