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

Leave a Reply

2 Comment threads
2 Thread replies
Most reacted comment
Hottest comment thread
4 Comment authors
PierreDavid SamuelssonArduinoModulesVladimir Recent comment authors
David Samuelsson
David Samuelsson

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.


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