17
Light Sensor
KY-018
Light Sensor (KY-018)
No. 17 • Analog

Light Sensor (KY-018)

อ่านค่าความเข้มแสงจาก LDR/photoresistor

Component NameLight Sensor
Part No. / ModelKY-018
Interface TypeAnalog
PinsS, VCC, GND

Note: ค่า analog อาจกลับทิศตามวงจรแบ่งแรงดันของโมดูล

Wiring Example

ตัวอย่างการต่อวงจรกับ Arduino UNO

Circuit diagram
Sensor PinArduino Pin
SA0
VCC5V
GNDGND

Arduino IDE Code

Download .ino file

ky-018-photoresistor.ino
// Light Sensor (KY-018)
// Board: Arduino UNO
// Read analog value from sensor module.

const int SENSOR_PIN = A0;

void setup() {
  Serial.begin(9600);
}

void loop() {
  int value = analogRead(SENSOR_PIN);
  Serial.print("Analog value: ");
  Serial.println(value);
  delay(500);
}