Skip to Content
Circuitera

Stop an Arduino threshold LED from flickering

A light reading hovering around 500 can cross a single threshold on successive samples.

0 of 3 complete · Progress saved on this device

Work out the example

A light reading hovering around 500 can cross a single threshold on successive samples. Give the ON and OFF transitions separate boundaries. This example turns on at 550 or higher and off at 450 or lower.

How many state changes occur in that sequence?

Decide what to check next

Start OFF. Apply 560, 520, 480, and 440. The two middle readings preserve the previous state. Use a serial trace before deciding that the real circuit has a wiring fault.

Compare with the serial result

Expected states are 1, 1, 1, 0. This sketch uses fixed samples to isolate the logic.

Open the exact Uno example

Expected states are 1, 1, 1, 0. This sketch uses fixed samples to isolate the logic.

void setup() {
  Serial.begin(9600);
  bool on = false;
  const int samples[] = {560, 520, 480, 440};
  for (int value : samples) {
    if (value >= 550) on = true;
    if (value <= 450) on = false;
    Serial.println(on);
  }
}
void loop() {}

Verified with [email protected] on Uno R3 (2026-12-05 UTC). This check did not use physical hardware.

Continue learning

Sources