// Button Example One (active high)
//
// Button not pressed: signal is LOW
// Button pressed : signal is HIGH
//
// The resistor keeps pin 8 low when the button
// is not pressed.
// The resistor is a pulldown resistor.
//
// Button Example One: https://wokwi.com/projects/397990618860958721
// Button Example Two: https://wokwi.com/projects/397990611031240705
//
// 16 May 2024, by Koepel, Public Domain.
#define buttonPin PA15
int oldValue = LOW; // default/idle value for pin 8 is low.
void keyPressed() {
Serial.println("pressed");
}
void setup()
{
Serial.begin(115200);
Serial.println("Press the button.");
// Initialize the pin for reading the button.
pinMode(buttonPin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(buttonPin),keyPressed,FALLING);
}
void loop()
{
Serial.println("Tick");
// Slow down the sketch.
// Also for debouncing the button.
delay(10000);
}