From 713417cde7dfd45f05ba7b5f224b7cab4e36e240 Mon Sep 17 00:00:00 2001 From: Christoph Haberer Date: Sun, 23 Apr 2017 14:23:05 +0200 Subject: [PATCH] UserButton example added --- .../Discovery407VG/UserButton/UserButton.ino | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 STM32/libraries/BoardExamples/examples/Discovery407VG/UserButton/UserButton.ino diff --git a/STM32/libraries/BoardExamples/examples/Discovery407VG/UserButton/UserButton.ino b/STM32/libraries/BoardExamples/examples/Discovery407VG/UserButton/UserButton.ino new file mode 100644 index 0000000..a31fe3f --- /dev/null +++ b/STM32/libraries/BoardExamples/examples/Discovery407VG/UserButton/UserButton.ino @@ -0,0 +1,34 @@ +// show user button state with blinking LEDs +// STM32F4 Discovery has one user button +// +// red LED: button pressed +// grenn LED: button not pressed + +#define USERBUTTON PA0 + +#define GREENLED PD12 +#define ORANGELED PD13 +#define REDLED PD14 +#define BLUELED PD15 +#define REDLEDOTGOVERCURRENT PD5 + +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); +}