Arduino Music

by misperry in Circuits > Arduino

545 Views, 2 Favorites, 0 Comments

Arduino Music

F7QZDJZKVKYPU65.jpeg

This is a tutorial on how to make music using the arduino. This reminds me of the music that was made for the old Nintendo system when there was no such thing as a DSP (digital signal processor), Back then all they had was 0V and 5V to play with. However, if you toggle these high/low at certain frequencies and pipe the voltage to a piezo speaker you can get what is basically video game music!

Supplies

Items you will need:


  • arduino
  • piezo speaker
  • 100ohm Resistor
  • small switch

Hardware Setup

circuit.png

First you will need to make the connections as follows.


The speaker will be connected through the 100ohm resistor to D8 on the Arduino board. Then you will connect the switch to port d12 and the other side to ground as shown.

The Coding

Now you will flash the super_mario code to your board that has the different pitches and frequency timing to support the simple super mario theme in it.



To change the melody you will use the pitches.h file to see what notes and octaves are defined. All you need to do is change the melody[] array. Now so far as the timing I based it all on 1sec intervals so a 8th note is 1000/8 and a quarter note is 1000/4. you can change this timing to increase/decrease the tempo.


Here are some links to the videos:

https://www.youtube.com/watch?v=CEEFmp73CI4&ab_channel=misperry

https://www.youtube.com/watch?v=7Vnl3cG3lLE&ab_channel=misperry