Skip to content

Commit 1b3cfdc

Browse files
authored
Individuall set feature
Added the feature to set individually the sensitivity of a touch button Added to display every buttons' getTouch event
1 parent 7644313 commit 1b3cfdc

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

examples/TouchPads/Custom_Sensitivity/Custom_Sensitivity.ino

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ MKRIoTCarrier carrier;
55
// When CARRIER_CASE is true it's set to 4 (further)
66
// But if you use Buttons.updateConfig(value) It will not set the above values
77

8-
unsigned int threshold = 100;
8+
unsigned int threshold = 98;
9+
unsigned int threshold_btn_0 = 95;
910

1011
void setup() {
1112
// put your setup code here, to run once:
@@ -14,15 +15,35 @@ void setup() {
1415

1516
//CARRIER_CASE = false;
1617
//Now we can set our custom touch threshold
18+
// First we update all the buttons with the new threshold
19+
// Then we overwrite individually one of them (they can be all set individually too)
1720
carrier.Buttons.updateConfig(threshold);
21+
carrier.Button0.updateConfig(threshold_btn_0);
1822
carrier.begin();
1923
}
2024

2125
void loop() {
2226
// put your main code here, to run repeatedly:
2327
carrier.Buttons.update();
24-
//Lets test 1 button, they should all react in the same way
28+
29+
// Verify your thresholds
2530
if (carrier.Button0.getTouch()) {
26-
Serial.println("touching");
31+
Serial.println("touching 0");
32+
}
33+
34+
if (carrier.Button1.getTouch()) {
35+
Serial.println("touching 1");
36+
}
37+
38+
if (carrier.Button2.getTouch()) {
39+
Serial.println("touching 2");
40+
}
41+
42+
if (carrier.Button3.getTouch()) {
43+
Serial.println("touching 3");
44+
}
45+
46+
if (carrier.Button4.getTouch()) {
47+
Serial.println("touching 4");
2748
}
2849
}

0 commit comments

Comments
 (0)