Comparing two analog input signals and outputting a digital signal

I have two analog inputs on A0 and A1. Both are on scales from 0-5000 (0-5 volts). A1 is connected to a variable resistor which is set at a certain value. A0 changes based on the environment. What I want to do is output a digital signal to turn on an alarm when A0’s is greater than or equal to the value of A1 but have the alarm stay off when the value of A0 is less that A1. HELP.

I'm not sure what's confusing you. Wouldn't it basically be:

var1 = analogRead(0);
var2 = analogRead(1);
if (var1 > var2)
 digitalWrite(pinOut, HIGH);
else
 digitalWrite(pinOut, LOW);

As long as you're using a 5V arduino your 0-5v will be scaled from 0-1023.

Probably need to do this to keep the signals from bleeding into each other:

var1 = analogRead(0); var1 = analogRead(0); // read twice, ignore first read

var2 = analogRead(1); var2 = analogRead(1); // read twice, ignore first read if (var1 > var2)

etc...