mirror of
https://github.com/jaksatomovic/esp32-clickwheel.git
synced 2025-08-28 07:28:29 -04:00
first commit
This commit is contained in:
commit
868b14f8c8
286 changed files with 59925 additions and 0 deletions
|
@ -0,0 +1,50 @@
|
|||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(ESP32)
|
||||
#error This sketch needs an ESP32
|
||||
#else
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Button2.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
Button2 button;
|
||||
byte pin = 4;
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
byte capStateHandler() {
|
||||
int capa = touchRead(pin);
|
||||
return capa < button.getDebounceTime() ? LOW : HIGH;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
delay(50);
|
||||
Serial.println("\n\nCapacitive Touch Demo");
|
||||
|
||||
button.setDebounceTime(35);
|
||||
button.setButtonStateFunction(capStateHandler);
|
||||
button.setClickHandler(click);
|
||||
button.begin(VIRTUAL_PIN);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
void loop() {
|
||||
button.loop();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
void click(Button2& btn) {
|
||||
Serial.println("click\n");
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
#endif
|
||||
/////////////////////////////////////////////////////////////////
|
Loading…
Add table
Add a link
Reference in a new issue