int sensorPin = 4; 
int ledPin = 2;     

void setup() {
  pinMode(ledPin, OUTPUT); 
  Serial.begin(9600);    
}

void loop() {
  int sensorValue = digitalRead(sensorPin); 
  Serial.println(sensorValue);             

  if (sensorValue ==1) { 
    digitalWrite(ledPin, HIGH); 
  } else {
    digitalWrite(ledPin, LOW); 
  }

  delay(100); 
}