-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuzzer.cpp
More file actions
47 lines (37 loc) · 787 Bytes
/
buzzer.cpp
File metadata and controls
47 lines (37 loc) · 787 Bytes
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
#include "buzzer.h"
Buzzer::Buzzer(int buzzerPin)
{
this->pin = buzzerPin;
}
void Buzzer::buzzerBeeping(int freq, int time) //Not possible to generate tones lower than 31Hz
{
tone(pin, freq, time);
}
void Buzzer::initBuzzer()
{
pinMode(this->pin, OUTPUT);
}
void Buzzer::entryBeeping() // passcode is correct
{
tone(pin, 262, 300);
delay(300);
tone(pin, 294, 300);
delay(300);
tone(pin, 330, 300);
delay(300);
}
void Buzzer::buttonPressed() // general sound when button pressed
{
tone(pin, 400, 100);
}
void Buzzer::alarm() // Enter incorrect passcode three times in a row
{
int i=0;
for(i;i<60;i=i+1)
{
tone(pin,1000,500);
delay(500);
tone(pin,500,500);
delay(500);
}
}