Skip to content

Commit 75becd5

Browse files
committed
Update PushEventButton demos.
Fixed comment in demo 3. Simplified comments for delay. Added Serial output in case it is required for debugging.
1 parent 42becd9 commit 75becd5

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

examples/PushEventButton_Demo_01/PushEventButton_Demo_01.ino

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ PushEventButton button(buttonPin, PushEventButton::CAPTURERELEASE);
2525

2626
void setup()
2727
{
28+
Serial.begin(9600);
29+
Serial.println("*** Push Event Button Counter Demo 01 ***");
30+
2831
// Setup the output LED.
2932
pinMode(ledPin, OUTPUT);
3033
digitalWrite(ledPin, LOW);
@@ -42,8 +45,7 @@ void loop()
4245

4346
if (buttonPushed)
4447
{
45-
// If the button was pushed, the light will be turned on. We need a brief delay to make sure the
46-
// on state of the LED is long enough to be seen.
48+
// We need a brief delay to make sure the LED is on long enough to be seen.
4749
delay(100);
4850
}
49-
}
51+
}

examples/PushEventButton_Demo_02/PushEventButton_Demo_02.ino

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ PushEventButton button(buttonPin, PushEventButton::CAPTUREPUSH);
2525

2626
void setup()
2727
{
28+
Serial.begin(9600);
29+
Serial.println("*** Push Event Button Counter Demo 02 ***");
30+
2831
// Setup the output LED.
2932
pinMode(ledPin, OUTPUT);
3033
digitalWrite(ledPin, LOW);
@@ -43,8 +46,7 @@ void loop()
4346

4447
if (buttonPushed)
4548
{
46-
// If the button was pushed, the light will be turned on. We need a brief delay to make sure the
47-
// on state of the LED is long enough to be seen.
49+
// We need a brief delay to make sure the LED is on long enough to be seen.
4850
delay(100);
4951
}
50-
}
52+
}

examples/PushEventButton_Demo_03/PushEventButton_Demo_03.ino

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,28 @@ PushEventButton button(buttonPin, PushEventButton::CAPTUREBOTH);
2525

2626
void setup()
2727
{
28+
Serial.begin(9600);
29+
Serial.println("*** Push Event Button Counter Demo 03 ***");
30+
2831
// Setup the output LED.
2932
pinMode(ledPin, OUTPUT);
3033
digitalWrite(ledPin, LOW);
3134
}
3235

3336
void loop()
3437
{
35-
// This will return true only once for each button push.
36-
// This example is triggered on the press of the button. As soon as the button is pressed down
37-
// this returns true. It does not matter how long the button is held down, the light flashes
38-
// for the same amount of time. Nothing happens on the button release.
38+
// This will return true once for the button push and once for the button release.
39+
// This example is triggered on the transition of the button. The LED will flash briefly on the button
40+
// push and briefly on the button release. It is recommended to hold the button down momentarily in order
41+
// to be able to distinquish between the push and the release events.
3942
bool buttonPushed = button.pushed();
4043

4144
// Set the LED to the state of the button press.
4245
digitalWrite(ledPin, buttonPushed);
4346

4447
if (buttonPushed)
4548
{
46-
// If the button was pushed, the light will be turned on. We need a brief delay to make sure the
47-
// on state of the LED is long enough to be seen.
49+
// We need a brief delay to make sure the LED is on long enough to be seen.
4850
delay(100);
4951
}
50-
}
52+
}

0 commit comments

Comments
 (0)