US1881 Hall switch

I'm having problems getting a signal from a US1881 Hall effect switch: datasheet

I've connected it on a breadboard as per diagram 13.1, but when I use the "Switch" example sketch, I only get a zero reading.

// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);

void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
    // turn LED on:
    digitalWrite(ledPin, HIGH);
  else {
    // turn LED off:
    digitalWrite(ledPin, LOW);

Have I killed the sensor with static? Or is it that some combination of code/hardware is wrong?

“Switch sketch”? Please post that sketch using code tags ( </> ).

So I can now get the sensor to switch, but it doesn't latch as it should.

const int hall = 4;
const int led = 13;
int val = 0;
void setup() {
pinMode(hall, INPUT);
digitalWrite(led, LOW);

void loop() {
val = digitalRead(hall);
if(val = 0){
  digitalWrite(led, LOW);
  digitalWrite(led, HIGH);

if(val = 0)  <<should be if (val==0)

Nick Gammons common trap #3 Gammon Forum : Electronics : Microprocessors : Arduino programming traps, tips and style guide

Trap #3: Confusing “=” (assign) with “==” (compare)