diff --git a/STM32/libraries/BoardExamples/examples/Discovery429ZI/UserButton/UserButton.ino b/STM32/libraries/BoardExamples/examples/Discovery429ZI/UserButton/UserButton.ino new file mode 100644 index 0000000..e324fcc --- /dev/null +++ b/STM32/libraries/BoardExamples/examples/Discovery429ZI/UserButton/UserButton.ino @@ -0,0 +1,32 @@ +// show user button state with blinking LEDs +// STM32F429 Discovery has one user button +// +// red LED: button pressed +// grenn LED: button not pressed + +#define USERBUTTON PA0 + + +#define GREENLED PG13 +#define REDLED PG14 + +void setup() +{ + pinMode(USERBUTTON, INPUT); // mandatory for STM MCUs, on Arduino Uno working without + pinMode(GREENLED, OUTPUT); + pinMode(REDLED, OUTPUT); +} + +void loop() +{ + if ( digitalRead(USERBUTTON) )digitalWrite(REDLED , HIGH); + else digitalWrite(GREENLED, HIGH); + + delay(100); + + // leds off + digitalWrite(GREENLED, LOW); + digitalWrite(REDLED , LOW); + + delay(100); +}