Skip to content

Instantly share code, notes, and snippets.

@grimmdev
Created October 30, 2017 09:11
Show Gist options
  • Save grimmdev/961ebc272fe6b01b596ff2c336c08dee to your computer and use it in GitHub Desktop.
Save grimmdev/961ebc272fe6b01b596ff2c336c08dee to your computer and use it in GitHub Desktop.
Light Switch Arduino Sensor for Relay
#define LIGHT_PIN D6 // 0 = LIGHT | 1 = DARK
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println(light());
}
int light()
{
pinMode(LIGHT_PIN, INPUT);
return digitalRead(LIGHT_PIN);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment