Buzzer En: 두 판 사이의 차이

아두위키 : Arduwiki
잔글편집 요약 없음
잔글편집 요약 없음
3번째 줄: 3번째 줄:
[[파일:부저 사진.jpg|가운데|class=coders100]]
[[파일:부저 사진.jpg|가운데|class=coders100]]


== '''개요''' ==
== '''Overview''' ==
부저(Buzzer)는 소리를 발생시키는 장치로, 아두이노와 같은 마이크로컨트롤러 보드와 함께 사용되어 다양한 프로젝트에서 경고음, 알림음, 음악 등을 재생하는 데 활용됩니다. 부저는 크게 능동 부저(Active Buzzer)와 수동 부저(Passive Buzzer)로 나뉩니다.
A buzzer is a device that generates sound and is used in various projects with microcontroller boards like Arduino to play alarm sounds, notifications, music, etc. Buzzers are mainly divided into Active Buzzers and Passive Buzzers.


== '''Active Buzzer and Passive Buzzer''' ==


== '''능동 부저와 수동 부저''' ==
=== Active Buzzer ===
The active buzzer has an internal oscillation circuit that generates sound automatically when powered. It is easy to control and is mainly used to produce a sound at a constant frequency (without adjusting the pitch).


=== 능동 부저 (Active Buzzer) ===
'''Simple Control''' : It generates sound just by turning the power on and off.
능동 부저는 내부에 발진 회로가 내장되어 있어 전원을 공급하면 자동으로 소리를 발생시킵니다. 제어가 간단하며, 주로 일정한 주파수(음의 높낮이 조절없이 한 가지)의 소리를 내는 데 사용됩니다.
'''Constant Frequency''' : It only produces sound at a specific frequency.
=== Passive Buzzer ===
Unlike the active buzzer, which generates sound automatically when powered, a passive buzzer requires frequency control to produce sound. It can generate sounds of various frequencies using PWM (Pulse Width Modulation) signals, making it useful for playing melodies or various tones.


* '''간단한 제어''' : 단순히 전원을 켜고 끄는 것으로 소리를 발생시킵니다.
'''Complex Control''' : The frequency must be controlled externally or through software.
* '''일정한 주파수''' : 특정 주파수의 소리만 발생시킵니다.
'''Various Frequencies''' : It can produce sounds of various frequencies.




=== 수동 부저 (Passive Buzzer) ===
=== Distinction between Active and Passive Buzzers ===
수동 부저는 전원 공급 시 자동으로 소리를 내는 능동 부저와 달리 주파수를 제어해야 소리를 발생시킵니다. [[아날로그 핀과 PWM|PWM(Pulse Width Modulation)]] 신호를 사용하여 다양한 주파수의 소리를 생성할 수 있어, 멜로디나 다양한 음을 재생하는 데 유용합니다.
It can be difficult to distinguish between active and passive buzzers based on their appearance. Instead, they can be differentiated through a simple test.


* '''복잡한 제어''' : 외부 회로나 소프트웨어적으로 주파수를 제어해야 합니다.
==== 1. Labels and Markings ====
* '''다양한 주파수''' : 다양한 주파수의 소리를 발생시킬 수 있습니다.
This is a method of distinguishing based on appearance, but it may not be a definitive method as labeling can vary by product.


'''Active Buzzer''' : It usually has a label indicating "Active" or a specific frequency (e.g., "5V 12kHz").
'''Passive Buzzer''' : It often does not have a label indicating "Passive" or any frequency.
==== 2. Testing ====
The most certain method is to set up a simple circuit and differentiate them through testing.


=== 능동 부저와 수동 부저의 구분 ===
'''Active Buzzer''' : It produces sound immediately when power is connected.
능동 부저와 수동 부저는 외관 상으로는 구분하기 어려울 수 있습니다. 대신 간단한 테스트를 통해 구분합니다.
'''Passive Buzzer''' : It does not produce sound when power is connected, and sound is generated only when a frequency signal is input.
== '''Circuit Configuration''' ==
The form of the buzzer may vary depending on the product, but the circuit is configured based on the same principle.


==== 1. 레이블 및 마킹 ====
=== When there are 2 Pins ===
외관으로 구분하는 방법이지만, 제품에 따라 표기가 다를 수 있어 확실한 방법은 아닙니다.


* '''능동 부저''' : 보통 "Active" 또는 특정 주파수(예: "5V 12kHz")가 표시된 라벨이 붙어 있을 수 있습니다.
Connect the + terminal of the buzzer to a digital pin on the Arduino.
* '''수동 부저''' : "Passive" 또는 주파수 표시가 없는 경우가 많습니다.
Connect the - terminal of the buzzer to the GND of the Arduino. [[File:buzzer_circuit.png|center|class=coders100]]
=== When there are 3 Pins ===


==== 2. 테스트 ====
Connect the + terminal (or VCC) of the buzzer to the 5V pin on the Arduino.
가장 확실한 방법은 간단한 회로를 구성하여 테스트를 통해 구분하는 것입니다.
Connect the - terminal of the buzzer to the GND of the Arduino.
Connect the digital pin terminal of the buzzer to a digital pin you will use on the Arduino. '''※ If the model is different from the photo below, the pin positions may vary, so be sure to check the connections carefully.'''
[[파일:부저 3핀 회로.jpg|가운데|class=coders100]]


* '''능동 부저''' : 전원을 연결하면 바로 소리가 납니다.
== '''Usage Example''' ==
* '''수동 부저''' : 전원을 연결해도 소리가 나지 않으며, 주파수 신호를 입력해야 소리가 납니다.


=== 1. Controlling the Active Buzzer ===
This is an example of the active buzzer ringing 3 times.


== '''회로 구성''' ==
==== 1-1. Circuit Configuration ====
제품에 따라 부저 형태는 다를 수 있으나, 같은 원리로 회로를 구성합니다.
The image below shows an example using a product with 3 pins, but if you are using a product with 2 pins, please refer to the hardware connection section above for wiring.  
[[파일:능동부저 예제1 회로.png|가운데|class=coders100]]


=== 핀이 2개인 경우 ===
==== 1-2. Code ====
 
# 부저의 + 단자를 아두이노의 디지털 핀에 연결합니다.
# 부저의 - 단자를 아두이노의 GND에 연결합니다.
[[파일:수동부저 회로.png|가운데|class=coders100]]
 
 
=== 핀이 3개인 경우 ===
 
# 부저의 + 단자(혹은 VCC)를 아두이노의 5V 핀에 연결합니다.
# 부저의 - 단자를 아두이노의 GND에 연결합니다.
# 부저의 디지털 핀 단자를 아두이노에서 사용할 디지털 핀에 연결합니다.
'''※ 아래 사진과 다른 모델일 경우 핀의 위치가 다를 수 있으니 잘 확인해서 연결해야 합니다.'''[[파일:부저 3핀 회로.jpg|가운데|class=coders100]]
 
== '''활용 예제''' ==
 
=== 1. 능동 부저 제어 ===
능동 부저가 3번 울리는 예제입니다.
 
==== 1-1. 회로 구성 ====
아래 사진은 핀이 3개인 제품을 사용할 때 예시이지만, 핀이 2개인 제품을 사용하신다면 위 하드웨어 연결 항목을 참고하여 결선해주세요.[[파일:능동부저 예제1 회로.png|가운데|class=coders100]]
 
==== 1-2. 코드 ====
<syntaxhighlight lang="c++" line="1">
<syntaxhighlight lang="c++" line="1">
const int iopin = 7;
const int iopin = 7;
85번째 줄: 77번째 줄:




==== 1-3. 실행 결과 ====
==== 1-3. Execution Result ====
<div class="coders70">
<div class="coders70">
<youtube> Ow31hQcIxts </youtube>
<youtube> Ow31hQcIxts </youtube>
91번째 줄: 83번째 줄:




=== 2. 능동 부저와 [[택트 스위치(Tact Switch)|택트 스위치]] 혼합 활용 ===
=== 2. Mixed Use of Active Buzzer and [[Tact Switch|Tact Switch]] ===
[[택트 스위치(Tact Switch)|택트 스위치]]를 누르면 능동 부저가 소리를 발생시키는 예제입니다.
This example demonstrates how the active buzzer produces sound when the tact switch is pressed.


==== 2-1. 회로 구성 ====
==== 2-1. Circuit Configuration ====
해당 예제에서는 택트 스위치 연결 시 INPUT_PULLUP 저항을 활용합니다.
In this example, the INPUT_PULLUP resistor is used when connecting the tact switch.


PULLUP, PULLDOWN, INPUT_PULLUP 저항에 대한 자세한 설명은 [[택트 스위치(Tact Switch)|택트 스위치]] 문서를 참고해주세요.
For a detailed explanation of PULLUP, PULLDOWN, and INPUT_PULLUP resistors, please refer to the [[택트 스위치(Tact Switch)|택트 스위치]] document.


[[파일:부저 예제1 회로.jpg|가운데|class=coders100]]
[[파일:부저 예제1 회로.jpg|가운데|class=coders100]]


==== 2-2. 코드 ====
==== 2-2. Code ====
<syntaxhighlight lang="c++" line="1">
<syntaxhighlight lang="c++" line="1">
#define buzzer 6
#define buzzer 6
123번째 줄: 115번째 줄:




==== 2-3. 실행 결과 ====
==== 2-3. Execution Result ====
<div class="coders70">
<div class="coders70">
<youtube> T7I3b59x0QA </youtube>
<youtube> T7I3b59x0QA </youtube>
129번째 줄: 121번째 줄:




=== 3. 수동 부저 제어로 음계 재생 ===
=== 3. Playing Musical Notes with Passive Buzzer Control ===
수동 부저는 능동 부저와 달리 주파수를 제어하여 음을 다르게 표현할 수 있습니다.
Unlike the active buzzer, the passive buzzer can express different tones by controlling the frequency.
 
This is an example of playing the Do-Re-Mi-Fa-Sol-La-Si-Do scale in order.


도레미파솔라시도 음계를 순서대로 재생하는 예제입니다.
==== Reference Material: Standard Frequencies for Octaves and Notes ====


==== 참고자료 : 옥타브 및 음계별 표준 주파수 ====
[[파일:옥타브 및 음계별 표준 주파수.png|가운데|class=coders100]]
[[파일:옥타브 및 음계별 표준 주파수.png|가운데|class=coders100]]




==== 3-1. 회로 구성 ====
==== 3-1. Circuit Configuration ====
하드웨어 연결 탭의 회로를 참고하세요.
Please refer to the circuit in the hardware connection tab.




==== 3-2. 코드 ====
==== 3-2. Code ====
<syntaxhighlight lang="c++" line="1">
<syntaxhighlight lang="c++" line="1">
#define buzzer 11
#define buzzer 11
int numTones = 8;
int numTones = 8;


//순서대로 (4옥도,4옥레,4옥미,4옥파,4옥솔,4옥라,4옥시,5옥도)
//순서대로 (4th Octave Do, 4th Octave Re, 4th Octave Mi, 4th Octave Fa, 4th Octave Sol, 4th Octave La, 4th Octave Si, 5th Octave Do)
double tones[] = { 261.6256, 293.6648, 329.6276, 349.2282, 391.9954, 440, 493.8833, 523.2511 };
double tones[] = { 261.6256, 293.6648, 329.6276, 349.2282, 391.9954, 440, 493.8833, 523.2511 };


163번째 줄: 156번째 줄:
         for (int i = 0; i < numTones; i++)
         for (int i = 0; i < numTones; i++)
         {
         {
             //tone(핀번호, 주파수)로 사용합니다.
             //tone(Pin number, Frequency)로 사용합니다.
             tone(buzzer, tones[i]);
             tone(buzzer, tones[i]);
             delay(500);
             delay(500);
         }
         }
         //noTone함수를 사용하지 않을 시 이전에 입력된 tone함수가 계속 실행이 되므로
         // If the noTone function is not used, the previously entered tone function will continue to execute,
         //noTone함수로 소리를 꺼줍니다.
         // so we use the noTone function to turn off the sound.
         noTone(buzzer);
         noTone(buzzer);
         delay(500);
         delay(500);
177번째 줄: 170번째 줄:




==== 3-3. 실행 결과 ====
==== 3-3. Execution Result ====
<div class="coders70">
<div class="coders70">
<youtube> vayYbS_Qjy0 </youtube>
<youtube> vayYbS_Qjy0 </youtube>
183번째 줄: 176번째 줄:




=== 4. 수동 부저 제어로 멜로디 재생 ===
=== 4. Playing Melody with Passive Buzzer Control ===
수동 부저로 간단한 멜로디를 재생하는 예제입니다.
This is an example of playing a simple melody with a passive buzzer.


본 예제를 바탕으로 다른 멜로디를 재생하도록 변형이 가능합니다.
You can modify this example to play other melodies.


==== 4-1. 회로 구성 ====
==== 4-1. Circuit Configuration ====
하드웨어 연결 탭의 회로를 참고하세요.
Please refer to the circuit in the hardware connection tab.




==== 4-2. 코드 ====
==== 4-2. Code ====
<syntaxhighlight lang="c++" line="1">
<syntaxhighlight lang="c++" line="1">
#define buzzer 11
#define buzzer 11
198번째 줄: 191번째 줄:
int numTones = 8;
int numTones = 8;
double g_tones[] = { 195.9977, 220, 246.9417, 261.6256, 293.6648, 329.6276, 349.2282, 391.9954 };
double g_tones[] = { 195.9977, 220, 246.9417, 261.6256, 293.6648, 329.6276, 349.2282, 391.9954 };
//솔0,라1,시2,도3,레4,미5,파6,솔7
//Sol 0, La 1, Si 2, Do 3, Re 4, Mi 5, Fa 6, Sol 7
int cnt = 0;
int cnt = 0;


282번째 줄: 275번째 줄:




==== 4-3. 실행 결과 ====
아래는 요청하신 한글 부분의 영어 번역입니다.
영상 첨부 예정


==== 4-3. Execution Result ====
Video attachment to be provided


== '''기타 활용 예시''' ==
== '''Other Usage Examples''' ==
부저는 소리가 필요한 다양한 프로젝트에서 활용될 수 있습니다.
Buzzers can be used in various projects where sound is needed.


* '''알람 시스템''': 특정 조건이 만족될 때 경고음을 울리는 시스템
'''Alarm System''': A system that emits a warning sound when certain conditions are met
* '''타이머''': 시간 경과를 알리는 소리
'''Timer''': A sound that indicates the passage of time
* '''음악 재생''': 간단한 멜로디나 효과음을 재생하는 장치
'''Music Playback''': A device that plays simple melodies or sound effects
* '''게임''': 게임에서의 효과음이나 승리/패배 알림음
'''Games''': Sound effects or victory/defeat notification sounds in games




== '''구매링크''' ==
== '''Purchase Link''' ==


* '''[https://gongzipsa.com/shop/search.php?q=%EB%B6%80%EC%A0%80 공집사몰]'''
* '''[https://gongzipsa.com/shop/search.php?q=%EB%B6%80%EC%A0%80 공집사몰]'''

2024년 8월 9일 (금) 10:12 판


Overview

A buzzer is a device that generates sound and is used in various projects with microcontroller boards like Arduino to play alarm sounds, notifications, music, etc. Buzzers are mainly divided into Active Buzzers and Passive Buzzers.

Active Buzzer and Passive Buzzer

Active Buzzer

The active buzzer has an internal oscillation circuit that generates sound automatically when powered. It is easy to control and is mainly used to produce a sound at a constant frequency (without adjusting the pitch).

Simple Control : It generates sound just by turning the power on and off. Constant Frequency : It only produces sound at a specific frequency.

Passive Buzzer

Unlike the active buzzer, which generates sound automatically when powered, a passive buzzer requires frequency control to produce sound. It can generate sounds of various frequencies using PWM (Pulse Width Modulation) signals, making it useful for playing melodies or various tones.

Complex Control : The frequency must be controlled externally or through software. Various Frequencies : It can produce sounds of various frequencies.


Distinction between Active and Passive Buzzers

It can be difficult to distinguish between active and passive buzzers based on their appearance. Instead, they can be differentiated through a simple test.

1. Labels and Markings

This is a method of distinguishing based on appearance, but it may not be a definitive method as labeling can vary by product.

Active Buzzer : It usually has a label indicating "Active" or a specific frequency (e.g., "5V 12kHz"). Passive Buzzer : It often does not have a label indicating "Passive" or any frequency.

2. Testing

The most certain method is to set up a simple circuit and differentiate them through testing.

Active Buzzer : It produces sound immediately when power is connected. Passive Buzzer : It does not produce sound when power is connected, and sound is generated only when a frequency signal is input.

Circuit Configuration

The form of the buzzer may vary depending on the product, but the circuit is configured based on the same principle.

When there are 2 Pins

Connect the + terminal of the buzzer to a digital pin on the Arduino.

Connect the - terminal of the buzzer to the GND of the Arduino.

파일:Buzzer circuit.png

When there are 3 Pins

Connect the + terminal (or VCC) of the buzzer to the 5V pin on the Arduino. Connect the - terminal of the buzzer to the GND of the Arduino. Connect the digital pin terminal of the buzzer to a digital pin you will use on the Arduino. ※ If the model is different from the photo below, the pin positions may vary, so be sure to check the connections carefully.

Usage Example

1. Controlling the Active Buzzer

This is an example of the active buzzer ringing 3 times.

1-1. Circuit Configuration

The image below shows an example using a product with 3 pins, but if you are using a product with 2 pins, please refer to the hardware connection section above for wiring.

1-2. Code

const int iopin = 7;

void setup() {
  pinMode(iopin, OUTPUT);
  digitalWrite(iopin, HIGH);
  for (int i = 0; i < 3; i++) {
    digitalWrite(iopin, LOW);
    delay(500);
    digitalWrite(iopin, HIGH);
    delay(500);
  }
}

void loop() {
  delay(10);
}


1-3. Execution Result


2. Mixed Use of Active Buzzer and Tact Switch

This example demonstrates how the active buzzer produces sound when the tact switch is pressed.

2-1. Circuit Configuration

In this example, the INPUT_PULLUP resistor is used when connecting the tact switch.

For a detailed explanation of PULLUP, PULLDOWN, and INPUT_PULLUP resistors, please refer to the 택트 스위치 document.

2-2. Code

#define buzzer 6
#define btn 12

void setup() {
  pinMode(buzzer, OUTPUT);
  pinMode(btn, INPUT_PULLUP);
}

void loop() {
  if (!digitalRead(btn)) {
    for (int i = 0; i < 6; i++) {
      digitalWrite(buzzer, !digitalRead(buzzer));
      delay(100);
    }
  }
  delay(10);
}


2-3. Execution Result


3. Playing Musical Notes with Passive Buzzer Control

Unlike the active buzzer, the passive buzzer can express different tones by controlling the frequency.

This is an example of playing the Do-Re-Mi-Fa-Sol-La-Si-Do scale in order.

Reference Material: Standard Frequencies for Octaves and Notes


3-1. Circuit Configuration

Please refer to the circuit in the hardware connection tab.


3-2. Code

#define buzzer 11
int numTones = 8;

//순서대로 (4th Octave Do, 4th Octave Re, 4th Octave Mi, 4th Octave Fa, 4th Octave Sol, 4th Octave La, 4th Octave Si, 5th Octave Do)
double tones[] = { 261.6256, 293.6648, 329.6276, 349.2282, 391.9954, 440, 493.8833, 523.2511 };

int cnt = 0;

void setup()
{

}

void loop()
{
    if (cnt == 0)
    {
        for (int i = 0; i < numTones; i++)
        {
            //tone(Pin number, Frequency)로 사용합니다.
            tone(buzzer, tones[i]);
            delay(500);
        }
        // If the noTone function is not used, the previously entered tone function will continue to execute,
        // so we use the noTone function to turn off the sound.
        noTone(buzzer);
        delay(500);
        cnt++;
    }
}


3-3. Execution Result


4. Playing Melody with Passive Buzzer Control

This is an example of playing a simple melody with a passive buzzer.

You can modify this example to play other melodies.

4-1. Circuit Configuration

Please refer to the circuit in the hardware connection tab.


4-2. Code

#define buzzer 11

int numTones = 8;
double g_tones[] = { 195.9977, 220, 246.9417, 261.6256, 293.6648, 329.6276, 349.2282, 391.9954 };
//Sol 0, La 1, Si 2, Do 3, Re 4, Mi 5, Fa 6, Sol 7
int cnt = 0;

void setup()
{

}

void loop()
{
    if (cnt == 0)
    {
        tone(buzzer, g_tones[0]);
        delay(250 * 2);
        noTone(buzzer);
        tone(buzzer, g_tones[3]);
        delay(250 * 2);
        noTone(buzzer);
        tone(buzzer, g_tones[2]);
        delay(125 * 2);
        noTone(buzzer);
        tone(buzzer, g_tones[3]);
        delay(125 * 2);
        noTone(buzzer);
        tone(buzzer, g_tones[4]);
        delay(250 * 2);
        noTone(buzzer);
        tone(buzzer, g_tones[3]);
        delay(125 * 2);
        noTone(buzzer);
        tone(buzzer, g_tones[4]);
        delay(125 * 2);
        noTone(buzzer);
        tone(buzzer, g_tones[5]);
        delay(125 * 2);
        noTone(buzzer);
        tone(buzzer, g_tones[5]);
        delay(125 * 2);
        noTone(buzzer);
        tone(buzzer, g_tones[6]);
        delay(125 * 2);
        noTone(buzzer);
        tone(buzzer, g_tones[5]);
        delay(125 * 2);
        noTone(buzzer);
        tone(buzzer, g_tones[1]);
        delay(250 * 2);
        noTone(buzzer);
        tone(buzzer, g_tones[4]);
        delay(125 * 2);
        noTone(buzzer);
        tone(buzzer, g_tones[4]);
        delay(125 * 2);
        noTone(buzzer);
        tone(buzzer, g_tones[3]);
        delay(250 * 2);
        noTone(buzzer);
        tone(buzzer, g_tones[3]);
        delay(125 * 2);
        noTone(buzzer);
        tone(buzzer, g_tones[3]);
        delay(125 * 2);
        noTone(buzzer);
        tone(buzzer, g_tones[2]);
        delay(250 * 2);
        noTone(buzzer);
        tone(buzzer, g_tones[1]);
        delay(125 * 2);
        noTone(buzzer);
        tone(buzzer, g_tones[2]);
        delay(125 * 2);
        noTone(buzzer);
        tone(buzzer, g_tones[3]);
        delay(250 * 4);
        noTone(buzzer);
        cnt++;
    }else
    {

    }
}


아래는 요청하신 한글 부분의 영어 번역입니다.

4-3. Execution Result

Video attachment to be provided

Other Usage Examples

Buzzers can be used in various projects where sound is needed.

Alarm System: A system that emits a warning sound when certain conditions are met Timer: A sound that indicates the passage of time Music Playback: A device that plays simple melodies or sound effects Games: Sound effects or victory/defeat notification sounds in games


Purchase Link