/
sound.ino
83 lines (69 loc) · 1.21 KB
/
sound.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
byte fireSound;
byte hitSound;
byte fallSound;
void ringSound() {
ringFireSound();
ringHitSound();
ringFallSound();
}
void playStartSound() {
tone(PIN_BUZZ, 1000);
delay(100);
noTone(PIN_BUZZ);
}
void playCatchSound() {
tone(PIN_BUZZ, 1500);
}
void playMissSound() {
tone(PIN_BUZZ, 500);
}
void startFireSound() {
fireSound = 5;
}
void startHitSound() {
hitSound = 7;
}
void startFallSound() {
fallSound = 4;
}
void ringFireSound() {
if (fireSound > 4) {
tone(PIN_BUZZ, 2500);
} else if (fireSound > 3) {
tone(PIN_BUZZ, 2300);
} else if (fireSound > 1) {
tone(PIN_BUZZ, 2120);
}
if (fireSound > 0) {
fireSound--;
}
}
void ringHitSound() {
if (hitSound > 6) {
tone(PIN_BUZZ, 2500);
} else if (hitSound > 5) {
tone(PIN_BUZZ, 2300);
} else if (hitSound > 3) {
tone(PIN_BUZZ, 1120);
} else if (hitSound > 1) {
tone(PIN_BUZZ, 1300);
}
if (hitSound > 0) {
hitSound--;
}
}
void ringFallSound() {
if (fallSound > 2) {
tone(PIN_BUZZ, 700);
} else if (fallSound > 1) {
tone(PIN_BUZZ, 300);
}
if (fallSound > 0) {
fallSound--;
}
}
void muteSound() {
if (fireSound + hitSound + fallSound == 0) {
noTone(PIN_BUZZ);
}
}