mirror of
https://github.com/Crocmagnon/buzzer.git
synced 2024-11-21 15:38:06 +01:00
Reduce sensitivity
This commit is contained in:
parent
c054d92c69
commit
a953f7d2d9
2 changed files with 10 additions and 4 deletions
|
@ -20,6 +20,8 @@
|
||||||
#define LED 2
|
#define LED 2
|
||||||
#define BUTTON 33
|
#define BUTTON 33
|
||||||
|
|
||||||
|
#define DEBOUNCE_DELAY 1000
|
||||||
|
|
||||||
// Screen
|
// Screen
|
||||||
#define SSD1306_NO_SPLASH
|
#define SSD1306_NO_SPLASH
|
||||||
#define SCREEN_WIDTH 128
|
#define SCREEN_WIDTH 128
|
||||||
|
|
12
src/main.cpp
12
src/main.cpp
|
@ -9,6 +9,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
byte buttonLastState = HIGH;
|
byte buttonLastState = HIGH;
|
||||||
|
long lastDebounceTime = 0;
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
|
@ -43,9 +44,12 @@ void setup()
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
byte buttonCurrentState = digitalRead(BUTTON);
|
if ((millis() - lastDebounceTime) > DEBOUNCE_DELAY)
|
||||||
if (buttonCurrentState == LOW && buttonLastState == HIGH)
|
{
|
||||||
play();
|
byte buttonCurrentState = digitalRead(BUTTON);
|
||||||
buttonLastState = buttonCurrentState;
|
if (buttonCurrentState == LOW && buttonLastState == HIGH)
|
||||||
|
play();
|
||||||
|
buttonLastState = buttonCurrentState;
|
||||||
|
}
|
||||||
audio.loop();
|
audio.loop();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue