-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSound_Level_Meter.ino
More file actions
74 lines (71 loc) · 1.26 KB
/
Copy pathSound_Level_Meter.ino
File metadata and controls
74 lines (71 loc) · 1.26 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
#include <LiquidCrystal.h>
byte Sh[] = {
B00000,
B10101,
B10101,
B10101,
B10101,
B10101,
B10101,
B11111
};
byte M[] = {
B00000,
B11011,
B11011,
B10101,
B10101,
B10001,
B10001,
B10001
};
LiquidCrystal lcd(7,6,5,4,3,2);
#define d_beep 9
#define MIC A2
void setup(){
lcd.begin(16,2);
lcd.createChar(0, Sh);
sh_letter = lcd.write(0);
m_letter = lcd.write(1);
lcd.createChar(1, M);
Serial.begin(9600);
pinMode(9,OUTPUT);
analogWrite(d_beep,0);
lcd.print(sh_letter);
lcd.print("y");
lcd.print(m_letter);
lcd.print("o");
lcd.print(m_letter);
lcd.print("ep");
delay(1000);
}
void loop(){
long mic_readings = analogRead(MIC);
lcd.setCursor(0,0);
lcd.print("= ");
lcd.print(mic_readings);
lcd.print("dB");
if (mic_readings >= 60){
lcd.setCursor(0,1);
lcd.print("Normal level");
}
if (mic_readings < 60){
lcd.setCursor(0,1);
lcd.print("Perfect level");
}
if (mic_readings >= 90){
lcd.setCursor(0,1);
lcd.print("Dangerous level");
analogWrite(d_beep, 51);
delay(1000);
analogWrite(d_beep, 153);
delay(1000);
analogWrite(d_beep, 0);
}
if (mic_readings = NULL){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("No readings");
}
lcd.clear();
}