5. Photo Resistor - Spark Core
Read data sheet for Photo Resistor (http://docs.spark.io/assets/datasheets/makerkit/photoresistor.pdf).
It says that resistance decreases with increasing light intensity. I understand it, but how can we use it? As first step, I think debug printing values would be
Found some instruction in community http://community.spark.io/t/photoresistor-how-to/3615/7
Goal here is "When it’s darker, we would see smaller resistance value”.
Code is really simple, we are using A0 analog port to read voltage. Please note that "input voltages between 0 and 3.3 volts into integer values between 0 and 4095.”
void setup() { Serial.begin(9600); // open serial over USB pinMode(A0, INPUT); } void loop() { Serial.println(analogRead(A0)); delay(500); }
I connected them as follows.
3V3 === Photo Resistor =#= 10K Ohm === GND.
# connected to A0 as well.
Let’s cover the photo resistor with your hand, yay it showed smaller value!
230 223 219 217 216 216 219 213 214 218 217 221 216 167 97 <== HERE 86 78 71 193 215 213 210 214
https://github.com/higepon/Spark-Core-Examples/blob/master/5.Photo%20Resistor.ino