Skip to content

Commit d9c82e9

Browse files
authored
arduino buzzer added
1 parent a7902a8 commit d9c82e9

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

buzzer/diagram.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"version": 1,
3+
"author": "Anonymous maker",
4+
"editor": "wokwi",
5+
"parts": [
6+
{ "type": "wokwi-arduino-uno", "id": "uno", "top": 45.33, "left": -32, "attrs": {} },
7+
{
8+
"type": "wokwi-buzzer",
9+
"id": "bz1",
10+
"top": -87.04,
11+
"left": 144.67,
12+
"attrs": { "volume": "0.1" }
13+
}
14+
],
15+
"connections": [
16+
[ "uno:8", "bz1:2", "green", [ "v-34.1", "h37.67" ] ],
17+
[ "bz1:1", "uno:GND.1", "black", [ "v3.48", "h-91.17" ] ]
18+
]
19+
}

buzzer/sketch.ino

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//Project Alarm
2+
float sinVal;
3+
int toneVal;
4+
5+
void setup(){
6+
pinMode(8,OUTPUT);
7+
}
8+
9+
void loop(){
10+
for(int x=0; x<180; x++){
11+
//convert angle of sinusoidal to radian measure
12+
sinVal = (sin(x*(3.1412/180)));
13+
//generate sound of different frequencies by sinusoidal value
14+
toneVal = 2000+(int(sinVal*1000));
15+
//Set a frequency for Pin-out 8
16+
tone(8, toneVal);
17+
delay(2);
18+
}
19+
}

buzzer/wokwi-project.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Downloaded from https://wokwi.com/projects/new/arduino-uno
2+
3+
Simulate this project on https://wokwi.com

0 commit comments

Comments
 (0)