Hi All,
To start with, I'm VERY much a beginner. So sorry for any stupid questions. Anyways...
I run a fishing boat and I'd like to play music through speakers on deck. However, when somebody calls me on the radio, I would like that to play instead of the music.
If that doesn't make sense, the following situation is analogous. I have two ipods and one set of speakers. I want to play music from iPod 1 through my speakers most of the time. However, if I press play on iPod 2, I want to hear that regardless of what iPod 1 is doing.
I haven't purchased a board for this project yet. I'm wondering if one model would work better than another. Any thoughts?
For now let's not worry about stereo audio. I can just set up two boards (one for left, one for right) if I can get one working for mono. Or maybe there's a clever way to do it with one board (I'm all ears).
Since sound signals are basically just voltage fluctuations, I'm thinking of doing something like the following (based soley on the examples in the tutorial section).
Thanks for the help!
int music = 1 //the music input is on pin 1
int radio = 2 //the radio input is on pin 2
int speakers = 3 //the speakers are connected to pin 3
const int threshhold = 50 //the threshhold value the radio feed must reach to cut in
void setup() {
pinMode(speakers, OUTPUT); //initialize the speakers as output
pinMode(music, INPUT); //initialize the music as input
pinMode(radio, INPUT); //initialize the radio as input
}
void loop() {
int radioValue = analogRead(2); //read the radio input value
int musicValue = analogRead(1); //read the music input value
if (radioValue<threshhold){
analogWrite(speakers, musicValue * (255/1023)) //send the music voltage value to the speakers
}
else{
analogWrite(speakers, radioValue * (255/1023)) //send the music voltage value to the speakers
}