From ab954f09ab5d4a206a19c418843be8719f563b7b Mon Sep 17 00:00:00 2001 From: Christoph Haberer Date: Mon, 24 Apr 2017 07:27:14 +0200 Subject: [PATCH] UserButton example for STM32F429 added --- .../Discovery429ZI/UserButton/UserButton.ino | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 STM32/libraries/BoardExamples/examples/Discovery429ZI/UserButton/UserButton.ino 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); +}