A1301 Hall Effect Sensor

leong92:
How am i going to program the arduino when led and sensor are plugged in? I want to let the LED switch OFF when magnet is near and switch ON when there are no magnet. i am using 1k Ohm resistor within the LED and the sensor. The sensor giving raw value of 514~516.

What does it go down or up to when you put the North pole of a magnet near the sensor face?
It should be a different value.
Something like this as an example if the value goes lower than 510:

  sensorVal = analogRead(sensorPin);
  if(sensorVal < 510){
    digitalWrite(ledPin, LOW);
  }
  else{
    digitalWrite(ledPin, HIGH);
  }