Speakers with Arduino

SPEAKERS ARDUINO INTERFACE

Arduino Speaker Setup


INTRODUCTION 

This Arduino project is one of the most simplest Arduino projects which you can build in minutes. The main thing which makes this project super simple is that this project requires only one extra component. If you are new to Arduino, this tutorial will help you get familiar with Arduino and learn the basics of Arduino programming.
This musical project has a speaker which plays out a song. If you ever wanted to add some sound to your existing project, you can do it easily with this Arduino speaker tutorial. You can even make a musical car reverse horn and make it play the latest songs always. You can change it easily by uploading a new program.
If you still remember how you made ringtones on those old Nokia cell phones, you pretty much have all the knowledge required to make any song with this project. Let’s get started.

What are the stuff required to do this?

  1. An Arduino
  2. A speaker or a piezo buzzer
  3. 2 connecting wires

How does it work?

The Arduino in this circuit creates tones of different frequencies and plays it through the speaker connected to it. The variation of the frequency of the tone(a.k.a. pitch) with correct timings(a.k.a. rhythm) creates music. The Arduino generates a signal and outputs it through the Digital pin 3. This drives the speaker connected to the pin to create sound. This can be used to play different songs by modifying this program. In this tutorial, I have programmed the Arduino speaker to play a song from the Malayalam movie ‘Ennu Ninte Moideen’.Arduino speaker
tone()
The program creates tones with a function, tone( )’. It g
enerates a square wave of the specified frequency (and 50% duty cycle) on a pin. A duration can be specified for this. Otherwise the wave continues until a call to noTone(). The Arduino pin can be connected to a piezo buzzer or other speaker to play the tones.Syntax:tone(pin, frequency) 
tone(pin, frequency, duration)
Parameterspin: the pin on which to generate the tonefrequency: the frequency of the tone in hertz – unsigned intduration: the duration of the tone in milliseconds (optional) – unsigned long
The code below uses an extra file, pitches.h. This file contains all the pitch values for typical notes. For example, NOTE_C4 is middle C. NOTE_FS4 is F sharp, and so forth. So instead of writing the frequency in the tone( ) function, we’ll just have to write the name of the note. This note table was originally written by Brett Hagman, on whose work the tone() command was based. You may find it useful whenever you want to make musical notes for your Arduino speaker.

How I made melody[ ] and noteDurations[ ] of this song:

If you take a look at the program, you can find two int arrays: melody[ ] and noteDurations[ ]. It is similar to how ringtones were written in old Nokia cell phones. The first array contains the notes and the second array contains its corresponding durations.
I found out the notes of this song with my guitar. I wrote down the musical notes of this song first and then wrote the melody[ ] array with that.
Then I wrote noteDurations[ ] according to the length of each music note. Here 8 = quarter note, 4 = 8th note, etc. Higher value gives longer duration notes. The note and its corresponding duration is what is there in melody[ ] and noteDurations[ ] respectively. You can modify those and create any song according to your wish!

Step 1: Connect the Arduino, speaker and power.

Connect a speaker or a piezo buzzer to the Arduino with one wire to the Digital pin 3 and the other one to the ground of the Arduino. Here’s what this project looks like:

Step 2: Upload the below code to the arduino

For downloading code click here
if You are unable to download from above link click here

HERE IS A VIDEO FOR YOU .......



Feedback

Please write the feedback in the comment box. Also write your quarry and the project you want. 

Comments

  1. i cant download im stupid!
    why dont you just make a print out and i will copy it!
    fills are cute if you know what to do with them.
    i just copy and paste.
    just print out the file.

    ReplyDelete

Post a Comment

Popular posts from this blog

Arduino with Speakers Project #01 a

QUADRATURE ENCODER