KY-018 PHOTORESISTOR MODULE

Click Here to View Step by Step

KY-018 PHOTORESISTOR MODULE


Short description :

The KY-018 Photoresistor module is used to measure light intensity.

Working with  (Compatible)

Arduino, ESP32, Nodemcu, ESP8266, Raspberry Pi, and ......

KY-018 PHOTORESISTOR MODULE

KY-018 PHOTORESISTOR MODULE

ARDUINO IDE CODE 

Example description :

The following Arduino sketch will output readings from the photoresistor, cover the module with your hand to prevent light on it and the output values will be low, point light to the sensor & the values will be high.

int led_pin = 13; // Define the LED interface
int switch_pin = 3; // Definition of mercury tilt switch sensor interface
int val; // Defines a numeric variable
void setup()
{
  pinMode(led_pin, OUTPUT);
  pinMode(switch_pin, INPUT);
}
void loop()
{
  val = digitalRead(switch_pin); // check mercury switch state
  if(val == HIGH)
  {
    digitalWrite(led_pin, HIGH);
  }
  else
  {
    digitalWrite(led_pin, LOW);
  }
}