-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_buzzer.c
More file actions
173 lines (161 loc) · 3.17 KB
/
_buzzer.c
File metadata and controls
173 lines (161 loc) · 3.17 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#include <avr/io.h>
#include <avr/io.h>
#define F_CPU 16000000UL
#include <util/delay.h>
#include <avr/interrupt.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "_main.h"
#include "_buzzer.h"
#define LDo 395
#define LRe 354
#define LMi 316
#define LFa 298
#define LSo 266
#define LLa 237
#define LSi 212
#define BDo 200
#define BRe 178
#define BMi 159
#define BFa 150
#define BSo 134
#define BLa 112
#define BSi 107
#define HDo 101
#define HRe 90
#define HMi 80
#define HFa 76
#define HSo 68
#define HLa 61
#define HSi 54
#define hDo 51
#define RB 50
#define LB 65
#define SB 30
#define BB 35
#define Buzzer_Port PORTG
#define Buzzer_Pin 4
#define MelOn SETBIT(Buzzer_Port, Buzzer_Pin)
#define MelOff CLEARBIT(Buzzer_Port, Buzzer_Pin)
void delay_us_Melody(int data)
{ int i; for(i=0;i<data;i++) { _delay_us(1); }}
void Sound(unsigned int ch, unsigned int time)
{
unsigned int tim;
tim=ch;
tim=tim*1000/time;
while(tim--)
{
MelOn;
delay_us_Melody(time);
MelOff;
delay_us_Melody(time);
}
}
void S_Good()
{ Sound(BB,BDo);
Sound(BB,BSo);
}
void SError(void)
{
Sound(SB,LDo);
}
void S_Push1()
{
Sound(SB,HDo);
Sound(SB,HMi);
}
void S_Start()
{
Sound(BB,HDo);
Sound(SB,HRe);
Sound(BB,HMi);
Sound(SB,HFa);
Sound(BB,HSo);
Sound(SB,HLa);
Sound(BB,HSi);
Sound(SB,hDo);
}
void S_S1()
{
Sound(BB,BDo);
Sound(BB,BMi);
Sound(BB,BSo);
Sound(BB,HDo);
}
void S_S2()
{
//Sound(BB,HDo);
//Sound(BB,HMi);
Sound(BB, HMi);
_delay_ms(400);
Sound(BB, HMi);
_delay_ms(400);
Sound(BB, BSi);
_delay_ms(200);
Sound(BB, HDo);
_delay_ms(200);
Sound(BB, HMi);
_delay_ms(400);
Sound(BB, HDo);
_delay_ms(200);
Sound(SB, HSi);
_delay_ms(200);
Sound(SB, HLa);
_delay_ms(400);
Sound(SB, HLa);
_delay_ms(200);
Sound(BB, HDo);
_delay_ms(200);
Sound(BB, HMi);
_delay_ms(400);
Sound(BB, HRe);
_delay_ms(200);
Sound(BB, HDo);
_delay_ms(200);
Sound(BB, BSi);
_delay_ms(400);
Sound(BB, BSi);
_delay_ms(200);
Sound(BB, HDo);
_delay_ms(200);
Sound(BB, HRe);
_delay_ms(400);
Sound(BB, HMi);
_delay_ms(400);
Sound(BB, HDo);
_delay_ms(400);
Sound(BB, BLa);
_delay_ms(400);
Sound(BB, BLa);
_delay_ms(400);
_delay_ms(1000);
}
void S_S3()
{
Sound(BB,LDo);
}
void S_S4()
{
Sound(BB,BDo);
Sound(BB,BMi);
Sound(BB,BSo);
}
void S_S5()
{
Sound(BB,BDo);
Sound(BB,BMi);
}
void S_S6()
{
unsigned char i;
for(i=0; i<4; i++)
{ Sound(BB,HSo); Sound(BB,HDo);
}
}
void S_S7()
{
Sound(BB,BDo);
Sound(BB,HDo);
}