Skip to content

Instantly share code, notes, and snippets.

@iotguider
Last active August 4, 2017 16:34
Show Gist options
  • Save iotguider/dace28e62286bfbd5c758ed52b691aad to your computer and use it in GitHub Desktop.
Save iotguider/dace28e62286bfbd5c758ed52b691aad to your computer and use it in GitHub Desktop.
Code for Interfacing LDR in Arduino
#define LDR A0 //Initialize LDR sensor pin.
void setup() {
//Begin the Serial Monitor at 9600 Baud
Serial.begin(9600);
}
void loop() {
int value = analogRead(LDR); //Store sensor value to variable
Serial.println(value); //Print the value to serial
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment