Skip to content

Instantly share code, notes, and snippets.

@tarunbod
Created January 23, 2016 22:26
Show Gist options
  • Save tarunbod/26c5654251d24950e6e7 to your computer and use it in GitHub Desktop.
Save tarunbod/26c5654251d24950e6e7 to your computer and use it in GitHub Desktop.
Arduino - Turn on LED based on Photoresistor value
void setup() {
pinMode(13, OUTPUT);
Serial.begin(9600);
}
void loop() {
int lightLevel = analogRead(0);
if (lightLevel < 150) {
digitalWrite(13, HIGH);
} else {
digitalWrite(13, LOW);
}
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment