Shekhar777

LDR ADC

Mar 29th, 2020
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define LDRpin A0 // pin where we connected the LDR and the resistor
  2.  
  3. int LDRValue = 0;     // result of reading the analog pin
  4.  
  5. void setup() {
  6.   Serial.begin(9600); // sets serial port for communication
  7. }
  8.  
  9. void loop() {
  10.   LDRValue = analogRead(LDRpin); // read the value from the LDR
  11.   Serial.println(LDRValue);      // print the value to the serial port
  12.   delay(100);                    // wait a little
  13. }
Add Comment
Please, Sign In to add comment