-
Notifications
You must be signed in to change notification settings - Fork 0
/
BuzzerPlayer.cpp
55 lines (50 loc) · 1.14 KB
/
BuzzerPlayer.cpp
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
#include "BuzzerPlayer.h"
BuzzerPlayer::BuzzerPlayer(unsigned int pin) {
_pin = pin;
}
void BuzzerPlayer::Init() {
for(int i = 0; i < 3; i++) {
tone(_pin, 1000);
delay(100);
noTone(_pin);
delay(100);
}
}
void BuzzerPlayer::Success() {
for(uint8_t i = 0; i < 2; i++) {
tone(_pin, NOTE_A5);
delay(NOTE_SUSTAIN);
tone(_pin, NOTE_B5);
delay(NOTE_SUSTAIN);
tone(_pin, NOTE_C5);
delay(NOTE_SUSTAIN);
tone(_pin, NOTE_B5);
delay(NOTE_SUSTAIN);
tone(_pin, NOTE_C5);
delay(NOTE_SUSTAIN);
tone(_pin, NOTE_D5);
delay(NOTE_SUSTAIN);
tone(_pin, NOTE_C5);
delay(NOTE_SUSTAIN);
tone(_pin, NOTE_D5);
delay(NOTE_SUSTAIN);
tone(_pin, NOTE_E5);
delay(NOTE_SUSTAIN);
tone(_pin, NOTE_D5);
delay(NOTE_SUSTAIN);
tone(_pin, NOTE_E5);
delay(NOTE_SUSTAIN);
tone(_pin, NOTE_E5);
delay(NOTE_SUSTAIN);
}
noTone(_pin);
}
void BuzzerPlayer::Chirp(unsigned int repeatTimes) {
for(int i = 0; i < repeatTimes; i++) {
tone(_pin,NOTE_G4);
delay(25);
tone(_pin,NOTE_C4);
delay(50);
noTone(_pin);
}
}