Play Music

Control the passive buzzer on the Robduino expansion board to play a short piece of music "Twinkle Twinkle Little Star".

Device connection

Hardware connection

Use Type-B data cable to connect Arduino Uno and computer.

Software connection

Open the "Arduino IDE" software and select the model and serial port number corresponding to the development board.

Buzzer control

Buzzers are divided into two types: active buzzers and passive buzzers.

Active buzzers: require external working voltage to emit fixed frequency sound;

Passive buzzers: require external circuit to provide driving signal, and control the pitch and loudness of the sound by changing the frequency and amplitude of the signal.

Control principle

Arduino's tone library can be used to control the digital pin on the Arduino board to output a square wave signal of a specified frequency, thereby driving the buzzer connected to the pin to play a specified tone.

Control pins

Peripheral moduleArduino Uno
Buzzer10

Code

Here we will only briefly introduce the code content. For detailed code, please refer to the corresponding code file, which is provided in the download area!

Experimental results

After compiling the program successfully, upload the code to the Arduino Uno development board.

After the program is started, the buzzer will play a short piece of music from the song "Twinkle Twinkle Little Star" in a loop!