skizziks_53

Reddit LDR checker v 1.0

Sep 18th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.81 KB | None | 0 0
  1. /*
  2.   LDR module checker ---- 18 September 2019
  3.  
  4.   This sketch is just for detecting an LDR module's sensitivity.
  5.   Specifically for the Keyes K853518 LDR module (or similar) that already has a voltage divider on it.
  6.  
  7.   This sketch prints the LDR's value to the serial monitor every 3 seconds.
  8. */
  9.  
  10. int ldr_out_pin = A0; // This should be a yellow wire on the module, labeled "OUT".
  11. int ldr_value = 0;
  12. // The VCC wire on the module gets connected to the 5v pin on the Arduino.
  13. // The black wire on the module gets connected to any ground pin on the Arduino.
  14.  
  15.  
  16. void setup() {
  17.   Serial.begin(9600);
  18.   pinMode(ldr_out_pin, INPUT);
  19.   Serial.println("Exiting setup()");
  20. }
  21.  
  22. void loop() {
  23.   ldr_value = analogRead(ldr_out_pin);
  24.   Serial.print("Sensor value = ");
  25.   Serial.println(ldr_value);
  26.   delay(3000);
  27. }
Add Comment
Please, Sign In to add comment