Sherlock Teams – Debounce and Noise
Estimated reading time: 9 minutes
I pressed it once, did it happen twice? – I thought I saw it and was wrong!
Debounce and Noise: Why this Article?
The systems we build in the classroom sometimes misunderstand our intentions. We press a button once, and it reacts twice. Just as the light is about to dim, it pops on and then goes out. Our robot brakes suddenly in the hallway; there’s no obstacle. So who’s to blame? Often, it’s two old friends: Debounce and Noise. This article proceeds with examples that middle school students will readily agree with, ” Oh yeah, ” and tools that teachers can integrate directly into their lesson plans. Our goal is a single sentence: “First draw the proof, then write the rule.” This way, it’s not enough to just say the circuit “worked”; we prove why it worked.
What is Debounce?
Brief description: Debounce is the short waiting window we use to count an event (pressing a button, touching, or seeing a line) as a single occurrence.
Why is it necessary? Mechanical and physical contacts cause on-off vibrations at the microscopic level. Our brain interprets this as a single event, but the circuitry may mistake these very rapid vibrations for separate events.
Examples you will feel immediately:
- Line-following Robot: At the edge of the line, the sensor sees black-white-black very quickly; the robot jumps “right-left-right!” Debounce turns these small flutters into a single decision.
- Drone Takeoff: When you push the joystick slightly, the potentiometer or switch may vibrate very briefly; the controller thinks this is multiple commands → tiny vibration.
- Garden Hose: When you turn the tap quickly, the valve opens and closes; water comes and goes like a short wave. Further, after a short pause, the flow regulates (debounce metaphor).
- Fork–Olive: Your hand trembles as you approach to pick up the olive; the fork barely touches the target and then withdraws. We want to say, “I took it in one go”—the idea of debounce.
- Ketchup Bottle: A little—a lot—a little with one squeeze… There’s a rebound at the bottleneck. The “one squeeze = one serving” goal is a debounce mentality.
Golden rule (Debounce): “ Open a short window, do not count the new event until that window is full. ” (typically 20–50 ms).
What is Noise?

Brief definition: Noise is unwanted random fluctuations in measurements. We’re not counting events here; we’re reading values (lux, temperature, distance, etc.).
Why does it happen? Natural factors like vibration, wind, sun glare, electrical interference, sensor heating, and surface gloss can make measurements fluctuate.
What does Noise look like in the Same Scenes?
- Line follower: Surface brightness fluctuates; light flashes on and off → sensor value jumps; robot thinks the line is on the edge.
- Drone flight: Wind and engine vibration create fine, rapid waves in the accelerometer; altitude fluctuates slightly.
- Hose: When the tip is shaken, it sprays water; it may appear that “the side pot is also wet” (incorrect measurement).
- Fork–olive: Hand tremor changes the distance to the target by +1 / –1 cm — this is measurement noise.
- Ketchup: Air bubbles inside make the flow appear uneven; “same squeeze” ≠ “same gram”.
Golden rule (Noise): “ Smoothen the measurement, eliminate the outliers, then decide. ” (median, lowpass, hysteresis, voting).
Debounce or Noise? (Difference at a Glance)
- Debounce = EVENT cleaning: Reduce the bounce to a single event in YES/NO situations, such as “I pressed-released”.
- Noise = MEASUREMENT cleanliness: Reduce fluctuations in numerical values such as Lux, distance, and temperature.
Quick Recipe:
- EVENT → Debounce + (if necessary) 2/3 voting
MEASUREMENT → Median(5) + Hysteresis + (if necessary) low pass.
In the Same Scenes, “What Should We Do?”

A) Line Following Robot
- Debounce: Open a 20–30 ms window when the sensor sees black; do not count even if it sees “white” before the window ends.
- Noise filter: Throw one shot flash with median(5).
- Hysteresis: Two thresholds, such as “Black < 300, White > 700”; decision change in between.
B) Drone Takeoff/Balance
- Debounce (command): Count the tiny vibrations from the arm as one command (20–30 ms).
- Noise (IMU/Baro): Soften with a low pass, kill one shot with Median(3).
- Vote: If 2 out of the last 3 decisions are the same, execute (against false commands).
C) Garden Hose (Playful Explanation)
- Debounce mind: Mini wait after turning the tap → single opening.
- Noise mind: If you shake the tip too much, the “metering” becomes unstable; soften the movement (filter metaphor).
D) Fork–Olives and Ketchup
- Debounce: “One move – one bite”; reduce quick, tiny touches to a single event.
- Noise: Hand tremor → distance to target is fluctuating; soften the flow/decision and make it later.
Mini-Experiments that will make you say “Oh yeah!” in Five Minutes
Experiment 1 — Button Debounce:
Plot the raw pin on the button–LED setup. Multiple peaks appear on a single press. Now add a 30 ms debounce → single peak.
👉 Student statement: “I pressed it once, it counted once.”
Experiment 2 — Light sensor (Noise):
Flash your phone flashlight briefly at the LDR. Thus, there are spikes in the raw graph.
Now Median(5) + Hysteresis → no flicker.
👉 Student: “It absorbs the momentary flash.”
Experiment 3 — Ultrasonic (False brake):
Sometimes see a false close measurement in an empty corridor.
Now Median(3) + 2/3 voting → false brake is close to zero.
👉 Student: “It’s safe, there’s a little delay, but it’s good.”

Experiment 4 — Mini greenhouse (relay tick):
Relay Click-click at single threshold; raw sensor fidgets.
Now, lowpass + hysteresis + min ON/OFF = silent graph.
Sherlock’s Reasoning Cards
- Cause–Effect: “What do I gain/lose if the debounce is 10→40 ms?”
- Design Choice: “What will be the delay if the median window is 3→7?”
- Hysteresis Logic: “What if the gap is too narrow/wide?”
- Sample Rate: “5 readings per second or 50? Noise-delay trade-off?”
Mini-Discussion: “The robot brakes a little later, but it doesn’t brake incorrectly. Thus, which would you choose in which scenario?”
Mini Rule Cards (Cut and Paste)
- Debounce: When an event is detected, ignore new events for 20–50 ms.
- Median(5): Take the median of the last 5 measurements; discard one beat.
- Low pass:
new = 0.7*old + 0.3*raw(example). - Hysteresis: Open < L , Close > H ; touch in range .
- 2/3 Voting: Apply if at least 2 of the last 3 decisions are the same.
Quick Pseudocode (For Ideas)
// Debounce - event
if (read != end) { tChange = now(); end = read; }
if (now() - tChange > 30 ms) status = last;
// Median(5)
sort = last5.sort();
filtered = sorted[2]; // median
// Hysteresis (light)
if (lux < 180) lamp = ON; else if (lux > 220) lamp = OFF;
Measure, Compare, Prove — Metrics
- Number of False Alarms: Neutral brake, unnecessary on/off.
- Vibration Score: Number of decision changes in 1 minute.
- Delay: The time from the actual event to the decision.
- Switching Cycles: Critical to relay/switch life.
- Wave Amplitude: What is ± for signals such as temperature?
Chart discipline: Plot “Before” and “After” graphs on the same axis. Hence, if you change the axis, you exaggerate/obscure the improvement.
Practical Guide to Parameter Selection
- Debounce time: 10–20 ms is a good start for most buttons; if you see a double trigger, try 30–50 ms. If it’s too long, quick clicks will be delayed.
- Median window: 3 fast; 5 stable; 7 very retardable.
- Alpha (low pass): 0.6–0.8 is soft, but not too delayed. 0.9 is too soft → reflex slows down.
- Hysteresis range: About 2–4 times the noise amplitude is a good start.
- Voting window: 2/3 stable and fast; 3/5 more stable but delayed.
Common Mistakes and Solutions
- “I added a filter, it got worse!” → Maybe you delayed it too much. Reduce the alpha/window.
- “Still vibrating.” → Your hysteresis range may be too narrow; it will increase the noise by 2–4 times.
- “False brake decreased, but real brake passed.” → Reduce voting/median window 3→2 or narrow hysteresis.
- “The graphs are nice, but the measurements are different.” → Fix the axes; remember to draw with the same scale.
- “The code is not working.” → Moreover, make sure you are updating the time (millis) correctly in Debounce; if you are using interrupts, update the shared variable atomically.
40–60 min Lesson Plan for Teachers
- Opening (5 min): 20–30 sec scene from Sora/Wan (button/line/drone). No spoilers.
- Hypothesis (5 min): Prediction with post-it notes: “Jumping”, “Noise”, “Cable”, “Code delay”…
- Gathering Evidence (10 min): Plot raw data (serial plotter, micro: bit plotter, Google Sheets).
- Rule Design (10 min): Group A = Debounce; B = Median; C = Hysteresis; D = Voting.
- A/B Test (10 min): Before/after, same condition–same axis. Write the metrics in the table.
- CER (5–10 min): 1 slide/poster: Claim–Evidence–Rationale + 1 graph + 1 number (false alarm).
- Expansion (option): Minimum ON/OFF (relay protection), playing with sampling rate.
Evaluation Rubric (10 points):
Data (2) • Rule (2) • A/B fairness (2) • Metric (2) • CER (2)
Cross-Course Bridges
- Math: Median = robust statistic; difference between mean and median.
- Physics: Vibration–damping; low pass = filter that reduces energy dissipation.
- Informatics: Decision logic, voting, state machines.
- Design & Ethics: “Safe or fast?” — real-world design choice.
Mini Projects for Home/School Club
- “Ghost lamp hunter”: Catch LDR flicker at window-corridor transitions and silence it with median + hysteresis.
- “No false brakes!”: Median(3) + 2/3 voting on ultrasonic ; reduce false brake counter to zero.
- “Silent greenhouse”: NTC + relay + low pass + hysteresis + min ON/OFF; tick log.
Why Do We Sometimes “Still” See Errors? (Deepening Box)
- Sample Rate: If you read too fast, you’ll see more noise; if you read too slow, you’ll miss a single beat, but latency will decrease. Design is a balancing act.
- Filter Delay: Low pass smooths but delays; the robot brakes a little later, in return eliminating false brakes.
- Threshold Selection: Single threshold = flicker; dual threshold = calm judgment. Range too wide → wave grows around target.
- Robust against bad data: Median kills single-shot; if a series of “bad” values follow, enlarge the window or support it with a vote.
“A Bridge to the Next Class” (For the Curious)
- Debounce ↔ Timing: The timescale of human intent is on the order of ms, so 20–50 ms windows are accurate.
- Noise ↔ Frequency World: Most of the noise is high frequency; the low-pass suppresses this part.
- Hysteresis ↔ Schmitt Trigger: Similarly, the same idea as analog threshold circuits.
- Voting ↔ Reliability: 2/3 majority logic works like multiple sensors seeking consensus.
- Bridge to PID: Good PID without reducing noise and bounce is hard; today’s steps are preparation for tomorrow’s PID lesson.
Sherlock Summary (Student Poster)
- Debounce = “I did it once; the system counts it once too.”
- Noise filter = “The measurement is choppy; smooth it first, then decide.”
- Evidence = “Same axis before/after; false alarm, delay, switching.”
- Teamwork = “Examine the same scene with both debounce and noise glasses.”
Conclusion and Call
Now distinguish between debounce and noise. We clean up the mess with debounce and calm down the measurement with median–lowpass–hysteresis–voting. Crucially, we do this with evidence: graphs, counters, comparisons. This is the spirit of Sherlock Teams: Observation → Rule → Experiment → CER.
Additionally, to stay updated with the latest developments in STEM research, visit ENTECH Online. Basically, this is our digital magazine for science, technology, engineering, and mathematics. Furthermore, at ENTECH Online, you’ll find a wealth of information.
References
- Ganssle, J. G. & The Ganssle Group. (2004). A guide to debouncing. In The Ganssle Group (p. 1). https://www.ee.iitm.ac.in/~nagendra/E4332/2005/handouts/digital/ganssle_debouncing.pdf
- Texas Instruments Incorporated. (2025). Understanding Schmitt triggers [Report]. https://www.ti.com/lit/ab/scea046b/scea046b.pdf?utm_source=chatgpt.com&ts=1749308914174
- Texas Instruments Incorporated. (2025). Comparator With and Without Hysteresis Circuit. https://www.ti.com/lit/an/sboa219b/sboa219b.pdf?ts=1761221019064



