Simple sensor

Very wrong!

Do something like:

If (analogRead(analogPin) > 50)
{
DiditalWrite(your_output,LOW);
}

Please use google because this is not the sort of question to ask, but rather the question to google.

These are the basics