I want to control the digital output with two analog inputs, something similar XOR gate with arduino comparator if possible..reference voltage Aref 2.5v and now if A input is greater than Aref and B input is less than Aref the digital output is high or if A is input smaller than Aref and B input larger than Aref output is high, that means if both inputs are the same output is Low...something like xor gate only with internal comparator
Thanks
which Arduino ? A Uno for example won't have a builtin xor gate as you describe nor the ability to use the builtin comparator to track 2 analog inputs. You'll need code or external hardware for that.
Hi,
Would this help;
Tom..
it could help @nokialkatel for sure if s/he goes the C++ way
Hi, @J-M-L
Yes, if he/she uses the same approach they did here, in 2017.
Tom...
yeah, clearly not rocket science
const int Max = 1023; // UNO, Mega
char s [90];
void
loop (void)
{
bool a1 = analogRead (A1) > Max/2;
bool a2 = analogRead (A2) > Max/2;
bool out = a1 ^ a2;
sprintf (s, " %d %d %d", out, a1, a2);
Serial.println (s);
delay (1000);
}
void
setup (void)
{
Serial.begin (9600);
}
thanks
What is mux in comparator..is it for two inputs
In general, an analog comparator allows you to compare two input voltages and output a signal indicating which is higher. The "MUX" (multiplexer) in this context refers to the ability to select different input sources for the comparator, such as different analog pins or the internal voltage reference
You did not answer this
Please take the time to provide relevant information for your question. Short sentences and SMS style posts don't get much answer here...
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.