#define SWITCH_PIN PB7 // Switch pin (using INPUT_PULLUP)
void setup() {
pinMode(SWITCH_PIN, INPUT_PULLUP); // Set switch pin as input with pull-up
Serial.begin(9600); // Start serial communication for debugging
}
void loop() {
int switchState = digitalRead(SWITCH_PIN); // Read the switch state
// Debugging output to Serial Monitor
Serial.print("Switch State: ");
Serial.println(switchState);
delay(500); // Check switch every 500ms
}
Loading
stm32-bluepill
stm32-bluepill