firedancer

Arduino robot LDR

Jul 30th, 2013
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.27 KB | None | 0 0
  1. int LDR = A5;
  2. int lux = 0; // Note the value from the sensor is not the real lux value ;-) max value is 1023.
  3. void checkLight() {
  4.   lux = analogRead(LDR);
  5.  
  6.   if (lux < 400) {  
  7.     analogWrite(headLights, 255);
  8.   } else {
  9.     analogWrite(headLights, 10);
  10.   }
  11. }
Advertisement
Add Comment
Please, Sign In to add comment