void setup() { pinMode(2, OUTPUT); } void loop() { if(digitalRead(2)==HIGH) //If sensor detects lid is open { digitalWrite(3, HIGH); } }