Tone Generation using Arduino
Aim:
To generate different audio tones using an Arduino UNO by interfacing a buzzer/speaker and
using the `tone()` function.
Apparatus Required:
* Arduino UNO
* Piezo buzzer / small speaker
* Connecting wires
* Breadboard (optional)
* USB cable
* Computer with Arduino IDE
Procedure
1. Connect the buzzer to the Arduino as per the circuit diagram.
2. Open Arduino IDE and write the program.
3. Select the correct board and COM port.
4. Upload the program to the Arduino.
5. Observe the buzzer producing different tones.
CODING:
int buzzer = 8;
setup()
{ void
pinMode(buzzer, OUTPUT);
}
void loop()
{
tone(buzzer, 500); // Generate 500 Hz tone
delay(1000);
tone(buzzer, 1000); // Generate 1000 Hz tone
delay(1000);
tone(buzzer, 1500); // Generate 1500 Hz tone
delay(1000);
noTone(buzzer); // Stop tone
delay(1000);
}
CIRCUIT DIAGRAM:
Result:
Different audio tones were successfully generated using Arduino UNO by
varying the frequency using the tone() function.