int LDRPin = 35; // ขาที่เชื่อมต่อกับ LDR
int LDRValue = 0; // ตัวแปรสำหรับเก็บค่าที่อ่านได้
void setup() {
Serial.begin(9600); // เริ่มต้นการสื่อสารผ่าน Serial Monitor
analogReadResolution(10); // ตั้งความละเอียดเป็น 10 บิต (ค่าในช่วง 0 ถึง 1023)
}
void loop() {
LDRValue = analogRead(LDRPin); // อ่านค่าจาก LDR
Serial.print("LDR Value: "); // แสดงผลใน Serial Monitor
Serial.println(LDRValue);
delay(500); // หน่วงเวลา 500ms
}