Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- LDR module checker ---- 18 September 2019
- This sketch is just for detecting an LDR module's sensitivity.
- Specifically for the Keyes K853518 LDR module (or similar) that already has a voltage divider on it.
- This sketch prints the LDR's value to the serial monitor every 3 seconds.
- */
- int ldr_out_pin = A0; // This should be a yellow wire on the module, labeled "OUT".
- int ldr_value = 0;
- // The VCC wire on the module gets connected to the 5v pin on the Arduino.
- // The black wire on the module gets connected to any ground pin on the Arduino.
- void setup() {
- Serial.begin(9600);
- pinMode(ldr_out_pin, INPUT);
- Serial.println("Exiting setup()");
- }
- void loop() {
- ldr_value = analogRead(ldr_out_pin);
- Serial.print("Sensor value = ");
- Serial.println(ldr_value);
- delay(3000);
- }
Add Comment
Please, Sign In to add comment