29
29
#define PIN_INPUT D3
30
30
#define PIN_LED D4
31
31
32
+ #elif defined(ESP32) && defined(ARDUINO_NANO_ESP32)
33
+ // For Arduino Nano ESP32 use D3 for button
34
+ #define PIN_INPUT D3
35
+ // For Arduino Nano ESP32 use e.g. LED_RED
36
+ #define PIN_LED LED_RED
37
+
32
38
#elif defined(ESP32)
33
39
// Example pin assignments for a ESP32 board
34
40
// Some boards have a BOOT switch using GPIO 0.
40
46
41
47
// Setup a new OneButton on pin PIN_INPUT
42
48
// The 2. parameter activeLOW is true, because external wiring sets the button to LOW when pressed.
43
- OneButton button (PIN_INPUT, true ) ;
49
+ OneButton * button;
44
50
45
51
// In case the momentary button puts the input to HIGH when pressed:
46
52
// The 2. parameter activeLOW is false when the external wiring sets the button to HIGH when pressed.
@@ -56,22 +62,23 @@ void setup()
56
62
Serial.begin (115200 );
57
63
Serial.println (" One Button Example with polling." );
58
64
59
- // enable the standard led on pin 13 .
65
+ // enable the standard led on pin PIN_LED .
60
66
pinMode (PIN_LED, OUTPUT); // sets the digital pin as output
61
-
62
- // enable the standard led on pin 13.
63
67
digitalWrite (PIN_LED, ledState);
64
68
69
+ // setup OneButton
70
+ button = new OneButton (PIN_INPUT, true );
71
+
65
72
// link the doubleclick function to be called on a doubleclick event.
66
- button. attachDoubleClick (doubleClick);
73
+ button-> attachDoubleClick (doubleClick);
67
74
} // setup
68
75
69
76
70
77
// main code here, to run repeatedly:
71
78
void loop ()
72
79
{
73
80
// keep watching the push button:
74
- button. tick ();
81
+ button-> tick ();
75
82
76
83
// You can implement other code in here or just wait a while
77
84
delay (10 );
0 commit comments