bouton-poussoir.ino
The classic button/LED circuit, identical to historic Arduinos: the R4 core keeps the same primitives (INPUT_PULLUP, digitalRead). The base of any human interface on the board.
Hardware
An Arduino UNO R4 Minima (Renesas RA4M1, Cortex-M4 @ 14 MHz, 5 V, 12-bit DAC, no radio) powered by USB or 6-24 V. 1 push button + 1 LED + 330 Ω resistor.
Wiring
Button between D2 and GND (internal pull-up). LED + 330 Ω between D13 and GND. Pins are 5 V tolerant (5 V compatible logic).
How it works
The reading is validated after 30 ms of stability; the press (LOW with pull-up) lights the LED and prints to the serial monitor.
Running it
Arduino IDE 2.x (with the « Arduino UNO R4 Boards » core installed), pick « Arduino UNO R4 Minima », select the port and Upload. The serial monitor runs at 9600.
Variants
Press counter shown on the matrix (R4 WiFi), or double-click with interval measurement between edges.
bouton-poussoir.ino
// Bouton sur D2 (vers GND) + LED sur D13, anti-rebond 30 ms.
const int BOUTON = 2;
const int LED = 13;
bool stable = HIGH, precedent = HIGH;
unsigned long dernierBord = 0;
void setup() {
pinMode(BOUTON, INPUT_PULLUP);
pinMode(LED, OUTPUT);
Serial.begin(9600);
}
void loop() {
bool lecture = digitalRead(BOUTON);
unsigned long maintenant = millis();
if (lecture != precedent) dernierBord = maintenant;
if (maintenant - dernierBord >= 30 && lecture != stable) {
stable = lecture;
digitalWrite(LED, stable == LOW); // appui -> LED
Serial.println(stable == LOW ? F("appui") : F("relache"));
}
precedent = lecture;
// Le RA4M1 est rapide (14 MHz) : le polling ne coute rien.
}