toneMelody Arduino

Title  : toneMelody

Date   : 23 November 2016

 

Apparatus :

  • Arduino UNO/Nano
  • Piezo Speaker/ Speaker biasa
  • wayar sambungan

 

Software:

  • pitches.h
  • toneMelody

Introduction:

toneMelody() function use PWM to generate different frequencies that could generate different sound. The tone function is shown like below:-

tonesample

For tone, the first number is the output pin, second – frequency, and third – node duration. We can use the sample code from Arduino IDE. We just go to:-

File>Example>Digital>toneMelody

Then we get the sample code as follows:-

samplecode

We need to make sure that, the connection of speaker pin out at the right pin. In this example, the pin out was set at D8.

Let try. Good luck.

Circuit:

speaker

UTM Open Day