Im working on a monitor controller that chooses from 3 input sources that can switch to speakers a,b,c.
Each input has a dedicated button to enable it(a relay), but upon activating the chosen input it must disable the other 2 since i only want to hear on input (ditto for the outputrelays).
Can anyone give an example how to write such exclusion ?
I think the issue is that Reply #1 addressed your question exactly, so your assertion that this was 'obviously' not your question makes no sense. The question answered was exactly the question you asked. When you start by dismissing people's attempts to help you, it's not exactly encouraging them to bother, is it?
The way I'd address this problem would be to have a function which read the inputs and returned the currently-selected input number (0 .. 2) and another function which output the selected input number (0 .. 2).
I don't know anything about your inputs, but for example if you have a momentary switch per input then you could put the switch input pin numbers in an array and loop through them testing to see whether any of them were active. In this situation I don't think you would need to bother with debouncing.
int getSelectedInput()
{
static int currentSelection = 0;
for(int i = 0; i < INPUT_COUNT; i++)
{
if(digitalRead(InputPins[i]) == LOW)
{
currentSelection = i;
}
}
return currentSelection;
}