LCENJ — Uno R3 input pull-up and bounded debounce exercise
Source license: MIT (see LICENSE.txt). This folder contains source, not a firmware updater.

ENGLISH
Target: Arduino Uno R3, ATmega328P, 16 MHz; FQBN arduino:avr:uno.
Disconnect power while wiring. Normally-open switch: board D2 -> switch -> GND.
No external pull-up resistor or connection of the switch to 5 V is used.
Identify the contacts of your actual switch; no four-leg switch orientation is assumed.
LED_BUILTIN (D13 on reference Uno) shows accepted pressed state when valid.

Open BoundedButton/BoundedButton.ino with the header alongside it.
Install Arduino AVR Boards 1.8.8 (the tested core); choose Arduino Uno.
From THIS folder:
  arduino-cli compile --fqbn arduino:avr:uno --warnings all BoundedButton
Compiling does not upload. Select a physical port only if you intend to upload yourself.
Serial monitor: 115200 baud. Pressed count increments once per qualified press.

Timing assumptions: 30 ms sampled settling; 200 ms fixed unsettled episode.
Each raw change restarts the settling interval, not the episode deadline.
Ready and Recovered are baselines, not edges; a button held at startup is not counted.
The fixed deadline wins when timeout and qualification are seen on the same call.
After Fault entry, recovery needs a fresh 30 ms sampled window.
valid() in Verify states describes the last accepted level, not the present raw signal.
update() must run regularly; unobserved pulses are invisible. Serial output can block.
A stuck input or disconnected wire cannot be diagnosed by this two-wire scheme.
Use chronological uint32 millisecond times, intervals <2^31 ms and short polling gaps.
No board upload, physical bounce capture, real loop-latency or noise test was performed.

Native tests execute BoundedButton/BoundedDebounce.h unchanged, not a reimplementation.
Example compiler commands from this folder (a native C++11 compiler is needed):
  g++ -std=c++11 -Wall -Wextra -Werror test_debounce.cpp -o test_debounce
  ./test_debounce
Tested on Windows using official portable Zig 0.14.1:
  zig c++ -std=c++11 -Wall -Wextra -Werror -Wno-unused-command-line-argument -fno-sanitize=all test_debounce.cpp -o test_debounce.exe
  test_debounce.exe
The driver-warning suppression is for Zig's Windows command line; source warnings remain errors.
No sanitizer qualification is claimed. No tests depend on a physical Uno.
The golden event trace is authored in test_debounce.cpp. Metamorphic tests shift that same
trace through modular time and duplicate observations; they do not duplicate the algorithm.

فارسی
هدف دقیق: Arduino Uno R3 با ATmega328P و فرکانس 16 MHz.
برای سیم‌کشی برق را قطع کنید. کلید معمولاً باز را بین D2 روی برد و GND ببندید.
کلید به 5V وصل نمی‌شود؛ پول‌آپ از داخل MCU فعال می‌شود.
زوج‌های مشترک کلید چهارپایهٔ خود را جداگانه شناسایی کنید؛ جهت نصب فرض نشده است.
فایل اسکچ را با هدر کنارش باز کنید، Arduino Uno را انتخاب و کامپایل کنید.
فرمان کامپایل و آزمون بومی در بخش انگلیسی همین فایل آمادهٔ کپی است.
کامپایل به معنی آپلود نیست. نرخ نمایش پیام سریال 115200 baud است.
برای هر فشار تأییدشده یک افزایش داریم؛ نگه‌داشتن باعث تکرار نمی‌شود.
۳۰ میلی‌ثانیه زمان ثبات مشاهده‌شده و ۲۰۰ میلی‌ثانیه مهلت دوره، فرض آموزشی‌اند.
رویدادهای Ready و Recovered فقط مبنا می‌سازند و فشار تازه شمرده نمی‌شوند.
در حالت بررسی، valid وضعیت پذیرفته‌شدهٔ قبلی را معتبر می‌داند، نه سطح خام فعلی را.
خطا همهٔ خرابی‌ها را تشخیص نمی‌دهد؛ سیم قطع یا اتصال دائم نیاز به بررسی جدا دارد.
نمونه‌های بین دو خواندن دیده نمی‌شوند و چاپ سریال ممکن است حلقه را متوقف کند.
آزمون رایانه همان فایل هدر استفاده‌شده در اسکچ را اجرا می‌کند.
این شواهد شامل آزمایش فیزیکی، آپلود، ثبت جهش تماس یا اندازه‌گیری نویز نیست.

Official sources / منابع رسمی:
https://docs.arduino.cc/resources/datasheets/A000066-datasheet.pdf
https://content.arduino.cc/assets/Pinout-UNOrev3_latest.pdf
https://content.arduino.cc/assets/ATmega328P_Datasheet.pdf
https://raw.githubusercontent.com/arduino/ArduinoCore-avr/1.8.8/cores/arduino/wiring_digital.c
https://raw.githubusercontent.com/arduino/ArduinoCore-avr/1.8.8/variants/standard/pins_arduino.h
https://raw.githubusercontent.com/arduino/ArduinoCore-avr/1.8.8/cores/arduino/wiring.c
