Skip to content

Instantly share code, notes, and snippets.

@labsguru
Created December 4, 2021 10:42
Show Gist options
  • Select an option

  • Save labsguru/c605c135fde3091f0d739ddccf29b5d8 to your computer and use it in GitHub Desktop.

Select an option

Save labsguru/c605c135fde3091f0d739ddccf29b5d8 to your computer and use it in GitHub Desktop.
int sensorPin = A2; // select the input pin for the potentiometer
int ledPin = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
} //https://kitsguru.myshopify.com/products/photosensitive-resistor-sensor-ldr-module-for-arduino
void loop() {
sensorValue = analogRead(sensorPin);
digitalWrite(ledPin, HIGH);
delay(sensorValue);
digitalWrite(ledPin, LOW);
delay(sensorValue);
Serial.println(sensorValue, DEC);
} //CREDITS : https://steps2make.com/2017/10/arduino-photo-resistor-module-ldr-ky-018/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment