Hi there all.
I have a project which involves sampling the light blocking properties of photoresistors.
I have a photo resistor, and an LED. The LED brightness changes, and the desire is that a serial analogue read from the photoresistor returns the brightness of the LED. This way i can acquire data on any filter placed inbetween the two components.
I acutally have two PRs, in order that i can use one as a control (not subjected to filtering), and the other as the test.
However my serial output is getting just NOISE.
I pressume this is because the LED brightness is being managed by PWM, and the PR is picking up, and reporting the strobing.
is there anyway i can smooth this out?
This is the offending section of code:
Serial.println("Comma Separated Values (CSV): First is X Axis, then PR1 value then PR2 value");
//Green Up
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
analogWrite(LEDG, fadeValue);
Serial.print(Scale += 1);
PR1 = analogRead(PR1);
Serial.print(",");
Serial.print(PR1);
PR2 = analogRead(PR2);
Serial.print(",");
Serial.print(PR2);
Serial.println(",");
the "Scale" value is there in order to provide an X axis, to graph the data
The data It is returning looks like this: I was hoping for a pair of fairly stable numbers
Comma Seperated Values (CSV): First is X Axis, then PR1 value then PR2 value
1,0,0,
2,107,109,
3,229,244,
4,245,260,
5,255,271,
6,0,0,
7,59,60,
8,205,217,
9,226,252,
10,260,247,
11,253,0,
12,63,85,
13,0,21,
14,57,48,
15,148,0,
16,68,73,
17,91,123,
18,153,155,
19,176,185,
20,0,64,
21,105,0,
22,32,61,
23,0,41,
24,64,65,
25,0,29,
26,66,71,
27,160,0,
28,0,42,
29,43,117,
30,188,167,
I think my hypothesis is correct...