float th=7800; // Set resistance threshold in Ohms int analogPin=0; int x=0; float Vout=0; float R=10000; //Known value Resistor in Ohm float resistor=0; float buffer=0; int op=7; void setup() { Serial.begin(9600); pinMode(op,OUTPUT); digitalWrite(op,LOW); } void loop() { x=analogRead(analogPin); buffer=x*5; Vout=(buffer)/1024.0; buffer=(5/Vout)-1; resistor=R*buffer; Serial.print("R = "); Serial.print(resistor); Serial.println(" Ohm"); if(th>resistor) // if resistance cross below threshold value, output is on, if you want opposite result use '<' // { digitalWrite(op,HIGH); Serial.println("Output is ON"); delay(3000); } else { digitalWrite(op,LOW); Serial.println("Output is OFF"); delay(3000); } }