KY-018 Photoresistor Module


Arduino KY-018 Photoresistor module, used to measure light intensity. It can determine the presence or absence of light.


This module consists of a photoresistor and a 10  in-line resistor. The photoresistor's resistance will decrease in the presence of light and increase in the absence of it. The output is analog and determines the intensity of light.

Operating Voltage3.3V to 5V
Output typeAnalog

KY-018 Connection Diagram

Connect the Power line (middle) and ground (-) to +5 and GND respectively. Connect signal (S) to pin A2 on the Arduino.

SPin A2
Arduino KY-018 Keyes photo resistor connection diagramclick to enlarge

KY-018 Example Code

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 a light to the sensor and the values will be high.

int sensorPin = 2; //define analog pin 2
int value = 0; 

void setup() {

void loop() {
	value = analogRead(sensorPin); 
	Serial.println(value, DEC); // light intensity
								// high values for bright environment
								// low values for dark environment

Inline Feedbacks
View all comments
Stefano Giugliano
Stefano Giugliano
1 month ago

Hello, I got high values for dark environments and viceversa. I’m using NodeMCU and KY-018 wired on A0 analog PIN.

Any idea of why?

David Samuelsson
David Samuelsson
1 year ago

There is no information on what photoresistor that is used. There are several types with different characteristics as resistance per lux input.
Example: GL5516, GL5528, GL5539 etc.
Would be much appreciated.

Reply to  David Samuelsson
1 year ago

I think it is the adafruit 161 photores

3 years ago

Great site!
Unfortunately CAPTCHA on this page is not visible and i cann’t download fzpz file.

Reply to  ArduinoModules
1 year ago

@ArduinoModules. Sorry sir, but the download button after solving the Captcha is not downloading..