Project showcase

Piezo Tunes © GPL3+

In this project, you're going to learn how you can play your own melody with a Piezo speaker, using code generated by Circuito.io

  • 4,483 views
  • 3 comments
  • 14 respects

Components and supplies

Apps and online services

circuito.io
https://www.circuito.io/app?selectedComponentsIds=11021&selectedComponentsIds=7950&selectedComponentsIds=9442

About this project

Follow the scheme in the Email from Circuito.io, and connect your breadboard.

Code it!

1. Open the firmware file you received from Circuito.io.

2. In order to play your tune, you need to change 3 parameters:

  • Length: add the number of notes in the melody.
  • Melody array: add a list of notes you want to play by their order in the melody. The number of notes in the array must match the Length int.
  • Note Duration Array: add a list of note durations:
4 = quarter note,
8 = eighth note, etc.

The number of note durations in the array must match the number of notes in the Melody Array and the Length int.

* We've highlighted the relevant parameters that you need to edit in the GIFS and images attached.

Play it!

1. To play the melody use the piezoSpeaker.playMelody function in the loop code section using the parameters and arrays above.

Make sure to update the names of the parameters if you changed them in the setup, for example, if you named your tune "Mario", you'll need to change the names of the parameters to MarioLength, MarioMelody and MarioNoteDuration.

Also make sure that the parameters are in the same order as they appeared above.

2. Upload the modified code to your Arduino.

** The code was created based on the Arduino Tone function.

Code

melody codeC/C++
No preview (download only).

Schematics

schematics
diagram_(2)_7rACwIp5ls.fzz

Comments

Similar projects you might like

34five Arduino Pet

Project showcase by circuito.io team

  • 918 views
  • 1 comment
  • 2 respects

Piezo Christmas Songs

Project showcase by joshi

  • 16,045 views
  • 18 comments
  • 48 respects

DHT11 Sensor with LEDs and a Piezo Speaker

Project tutorial by Tech with Matthew

  • 6,168 views
  • 3 comments
  • 19 respects

Portable Arduino Temp/Humidity Sensor with LCD

Project tutorial by ThothLoki

  • 153,297 views
  • 115 comments
  • 185 respects

Electronic Piano Keyboard With Preset Songs

Project tutorial by Lindsay Fox

  • 80,138 views
  • 61 comments
  • 160 respects

LED Dice

Project showcase by EvdS

  • 14,284 views
  • 11 comments
  • 49 respects
Add projectSign up / Login