1#include <CapacitiveSensor.h>
2int Value=0;
3int piezo=9;
4int frq=0;
5long D[10];
6long F=0;
7
8
9
10
11
12
13CapacitiveSensor cs_4_2 = CapacitiveSensor(4,2);
14
15int x=0;
16void setup()
17{
18 pinMode(piezo,OUTPUT);
19 cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF);
20 Serial.begin(9600);
21 digitalWrite(LED_BUILTIN,LOW);
22}
23
24
25
26
27
28
29
30
31
32
33
34
35
36void loop() {
37 long start = millis();
38
39
40
41
42
43
44 long Value = cs_4_2.capacitiveSensor(30);
45
46
47
48
49
50
51 delay(200);
52
53
54
55
56
57 if (Value>4000&&Value<30000){
58
59
60
61 }
62 if (Value>40000){
63 x=0;
64
65
66
67
68
69 }
70 Serial.println(Value);
71
72
73 frq=Value/200;
74 tone(piezo,frq);
75
76
77
78
79 }