Beginner - Independent Speakers

Hi guys, sorry if this is the wrong place!

What I am trying to do with some friends is a bit weird, but bare with me. It might be simple, but I am a total beginner both in programming and eletronics, and I could not solve this by reading the tutorials and guides around.

Right now what we need is to connect several speakers(or buzzers, do not matter), and the melody can be the same. The thing is, they must be independent of each other, triggered by buttons.

So we would have Button1 - Speaker 1, Button 2 - Speaker 2, etc. Why this? We need to do a little test of putting speakers in different points in a enclosed space, and be able to turn them on independently of each other, think that someone will be randomly pushing the buttons.

So here is the deal, I did made a system one button - one speaker, but could not connect two. When I connected two, the arduino went off - we are probably shorthing something, that's what me and my friend found out. But we really do not know where we are wrong since we checked with a friend who saysthat knows a little more about eletronics and apparently everything is okay.

So my situation is, it is possible to do this? I've read in some places saying that there is some problems connecting more thant 3 speakers. If you say that it is not possible, and the best solution is to get each speaker in one arduino it might be possible to us to obtain more with friends and the situation its solved. Not the best situation but well, part of life. (I foung the guy who put 5 speakers at the same time, but they work simultaneously...)

Any help would be appreciated =) What we have is Arduino Uno, and our speakers are 0.4W, 8 ohms if this makes any difference.

Buzzers will not play a melody. They buzz at a fixed note only.

Piezoelectric sounders will be the easiest thing to use, if they are loud enough for your purpose. They do not need an amplifier and can be driven by an Arduino output directly.

It will be too difficult for a beginner to get more than 3 speakers playing independently on a single Arduino. This is because to control the pitch of the note, a timer is needed, and most Arduino have only 3 timers. Even getting 3 to work well not be easy.

This is what I suggest: for each speaker, make a small circuit using an attiny45 or 85. These chips are like small Arduino with just a few pins. Each chip will be programmed to play its tune when an input is activated. You can use an Uno to make and test the circuit, then use the Uno to upload the sketch to the tiny chips. Each chip will be wired back to the central control board with the switches.

PaulRB:
Buzzers will not play a melody. They buzz at a fixed note only.

Piezoelectric sounders will be the easiest thing to use, if they are loud enough for your purpose. They do not need an amplifier and can be driven by an Arduino output directly.

It will be too difficult for a beginner to get more than 3 speakers playing independently on a single Arduino. This is because to control the pitch of the note, a timer is needed, and most Arduino have only 3 timers. Even getting 3 to work well not be easy.

This is what I suggest: for each speaker, make a small circuit using an attiny45 or 85. These chips are like small Arduino with just a few pins. Each chip will be programmed to play its tune when an input is activated. You can use an Uno to make and test the circuit, then use the Uno to upload the sketch to the tiny chips. Each chip will be wired back to the central control board with the switches.

Thanks so much for the help, we just ordered some of the AtTiny85 and will try soon! Will post here with the updates or new question after!

While you are waiting for the tiny chips, why not try out a piezoelectric speaker, to see if it is loud enough?
If not, you need to find a better way of driving your 0.4W speakers. You are probably not driving them correctly which is why the Arduino was resetting. It's possible to damage the Arduino doing that, so please post a schematic diagram showing how you wired the circuit (hand drawn is ok) and your code (only in code tags).

There are dedicated MP3 player chips and WAV player chips, some can store a melody and play it back on a regular loudspeaker. That's if you want more than a simple tone.

Hope you can manage the ATtiny chips. You'll need a dedicated programmer (an Arduino can help with this part) to get the software on, and because of their severe limitations of just 8 kB flash and 512 bytes RAM you have to be really careful with your programming. I wouldn't call them beginner-friendly, and possibly too hard to handle for someone who's not just beginner with Arduino, but also with programming and general electronics. Be prepared to engage on a really steep learning curve!

wvmarle:
just 8 kB flash and 512 bytes RAM you have to be really careful with your programming.

More than enough for reading a pushbutton and playing a melody. Even a beginner would struggle to overflow those limits with such a simple task.

wvmarle:
I wouldn't call them beginner-friendly, and possibly too hard to handle for someone who's not just beginner with Arduino, but also with programming and general electronics. Be prepared to engage on a really steep learning curve!

I am prepared to work through this one step at a time with the OP, as long as they are keen to learn. Have done this before with beginners. Yes, it will be a steep learning curve, but then so would have been getting an Uno to play 3 independent tunes at once, never mind more than 3.

Those mp3 player modules are great fun, have used them myself in projects. But they can be made to play just by connecting a button, no Arduino required, so the OP would learn far less.

Paul! Your help is really appreciated! I just spent the whole day at university (I live in Japan so my times are a bit weird) and will update here later with what we had.

Also, I first tried a normal buzzer, then the piezoeletric speaker. I also have some of those traditional speakers (Like this one in this link HERE). The sound volume is perfect for my needs. Unfortunately the speakers still did not arrive - did not had time to buy at Akihabara, and amazon seems to be delayed.

As I told, when I had only one button and one speaker/buzzer, they worked, and with melodies from the tutorials I found.

I don't mind the steep curve, I am really interested in learning and I hope this can work. Thanks so much for taking your time to help me =)

PaulRB:
Those mp3 player modules are great fun, have used them myself in projects. But they can be made to play just by connecting a button, no Arduino required, so the OP would learn far less.

Of course.
But sometimes you just want to get something done (especially if it's a one-off thing - the MP3 module route is probably a matter of minutes; the ATtiny route is going to be a matter of days or even weeks), sometimes you want to go down and dirty with it (if you expect to do more such projects). In the end up to OP which way to go; it's at least as important for this to be an informed decision.

Well, this took me about 15 minutes. I just made a few mods to the toneMelody example sketch.

Of course, I know what I'm doing, and I have a dedicated avr programmer. It will be somewhat slower to get this working using the Uno as the programmer, but I made a video about that previously also.

This video shows the same circuit but using an 8Ohm speaker.

This video shows the same circuit but using a bc337 npn transistor to drive the speaker.

Here is the modified toneMelody sketch:

/*
  Melody

 Plays a melody

 circuit:
 * 8-ohm speaker on digital pin 8

 created 21 Jan 2010
 modified 30 Aug 2011
 by Tom Igoe

This example code is in the public domain.

 http://www.arduino.cc/en/Tutorial/Tone

 */
#include "pitches.h"

// notes in the melody:
int melody[] = {
  NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3, 0, NOTE_B3, NOTE_C4
};

// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {
  4, 8, 8, 4, 4, 4, 4, 4
};

void setup() {
  pinMode(4, INPUT_PULLUP);
}

void loop() {

  while (digitalRead(4) == HIGH);
  
  // iterate over the notes of the melody:
  for (int thisNote = 0; thisNote < 8; thisNote++) {

    // to calculate the note duration, take one second
    // divided by the note type.
    //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
    int noteDuration = 1000 / noteDurations[thisNote];
    tone(2, melody[thisNote], noteDuration);

    // to distinguish the notes, set a minimum time between them.
    // the note's duration + 30% seems to work well:
    int pauseBetweenNotes = noteDuration * 1.30;
    delay(pauseBetweenNotes);
    // stop the tone playing:
    noTone(2);
  }
}

Here’s how much memory it uses:

Sketch uses 2,918 bytes (35%) of program storage space. Maximum is 8,192 bytes.
Global variables use 50 bytes (9%) of dynamic memory, leaving 462 bytes for local variables. Maximum is 512 bytes.