-
Contributor: Domenico Monaco domenico.monaco@kiuz.it
-
Link: http://kiuz.it
-
Tags: Arduino, photoresistor, light-dependent, LDR, photocell
-
License: MIT Licence
-
The code is partly taken from:
This is very simple code to use photoresistor (LDR) with Arduino.
In a "void setup()" the code read the the input and creates empirically two level (max and min), where "min" is simply smaller at will.
So in the "void loop()" the code reads the input and compares it with the min and max, if have checked new values of min or max updates them;
Obviously there are some prints into serial output to have a fedback of the changes into code.
Finally I have added a button to close the circuit to configure the code with the real maximum possible value into input, this is optional ad is usefull only for testing.
- 10k resistor, or a numbers of resistors to make 10K ohm
- is not very important that resistor is exactly 10k ohm, but you can change value based to the sensibility you want have. In example if you are in a room with very strong light you can use more of 10k ohm
- photoresistor
- button (optional)
source: http://bildr.org/2012/11/photoresistor-arduino/
Copyright (c) 2014 Domenico Monaco domenico.monaco@kiuz.it
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.