Making two arduinos play different parts of a song in tandem?

Hey guys, first post here. I have two arduino unos that I want to connect in order to play a song. One arduino plays the bass notes while the other plays the melody. Any ideas on how I would go about it?

Sorry if this is on the wrong board, haven't done too much digging.

Thanks!

You are on the right board, but this board works best if you properly post your code and ask for help in fixing it or improving it.

If you want code written for you, go to Gigs and Collaborations and bring your wallet.

Make them do the -exact- same thing. Read some file of music (Your choice) and play the notes. Then, have one Arduino start, and when it does, have it toggle a wire to the other Arduino to tell it to start playing its file. (And that file has the "other" notes.)

Then when you want 3 Arduinos, just give the third its file of notes and hook it to the same "start" wire.

Then a 4th..

-jim lee

Sounds like a good idea. Thanks!

Hey guys, I'm completely new to the Arduino platform and I have an issue. I need two UNOs to execute their commands at the exact same time. How would I go about about doing this?

Thanks for the help!

They'd have to be running off the same clock.

FiveTomb:
Hey guys, I'm completely new to the Arduino platform and I have an issue. I need two UNOs to execute their commands at the exact same time. How would I go about about doing this?

Thanks for the help!

Define "commands". Do you mean instruction or do you mean something telling the Arduinos to do something?

Paul

FiveTomb:
Hey guys, I'm completely new to the Arduino platform and I have an issue. I need two UNOs to execute their commands at the exact same time.

What is the technical meaning of "exact same time"?

Do you mean "same second? Or same millisecond? Or same microsecond?

And what is "their commands", in case you describe that term a bit more datailed?

jurs:
What is the technical meaning of "exact same time"?

Do you mean "same second? Or same millisecond? Or same microsecond?

And what is "their commands", in case you describe that term a bit more datailed?

The commands that I'm giving them is to play a melody. More specifically, the song of storms. I have one arduino playing the higher melody notes, and the other is playing the bass notes. Each is connected to a piezo speaker. I need them to start playing their parts at the exact same time.

Can you perceive a 20 or 30 microsecond time difference?

Groove:
Can you perceive a 20 or 30 microsecond time difference?

Definitely what I was thinking of doing. But for some reason the professor wants us to use two arduinos and two separate speakers.

FiveTomb:
The commands that I'm giving them is to play a melody. More specifically, the song of storms. I have one arduino playing the higher melody notes, and the other is playing the bass notes. Each is connected to a piezo speaker. I need them to start playing their parts at the exact same time.

Starting at the exact time might be arranged by making them wait for a signal from the same push button. DPST switch, or similar. The two will certainly not stay together for very long unless both boards use the same clock signals.

Can these Arduinos be placed right next to each other?

Paul

In what way is this different from your previous thread?

Pete

But for some reason the professor wants us to use two arduinos and two separate speakers.

Is this a professor of electronics or music?
He sounds like it is music and has no idea about electronics.

If the two Arduinos are close together it should be possible to link two I/O pins so that one Arduino can send a "metronome" signal to the other (perhaps once per second) and the receiving Arduino can use that to correct any drift in the value of millis().

...R

Basically this is an X-Y Problem

The OP doesn't want or need to run two Arduinos in syncronisim. That is just a simple minded and quite futile approach. All he needs to do is to trigger the second Arduino to make the sound at the right time. He could use MIDI protocol or in fact anything else to signal to the second superfluous Arduino to make a sound. Any delay will be totally inaudible.

@FiveTomb, do not cross-post. Threads merged.

Paul_KD7HB:
Starting at the exact time might be arranged by making them wait for a signal from the same push button. DPST switch, or similar. The two will certainly not stay together for very long unless both boards use the same clock signals.

Can these Arduinos be placed right next to each other?

Paul

Yes they can. But It can't be wireless though.

Grumpy_Mike:
Is this a professor of electronics or music?
He sounds like it is music and has no idea about electronics.

It's an engineering orientation class. We are collaborating with another group, hence the two arduinos playing different parts of a song. Don't know why he just won't let us use 2 piezos though.

FiveTomb:
It's an engineering orientation class. We are collaborating with another group, hence the two arduinos playing different parts of a song. Don't know why he just won't let us use 2 piezos though.

Piezos? I don't think it's a good idea to use piezos for playing music (could be wrong, but I doubt it's even feasible). You should be using electromagnetic speakers instead.

BTW, using an opamp in summing configuration, you can add the signals from both arduinos and play BOTH signals using one speaker!