Shekhar777

LDR ARDUNIO

Mar 29th, 2020
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define LDRpin 8  // pin where we connect LDR and 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 = digitalRead(LDRpin);// read the value from the LDR
  11.   Serial.println(LDRValue);      // print the value to the serial port
  12.   delay(100);  
  13.   // wait a little
  14. }
Add Comment
Please, Sign In to add comment