-->
Page 1 of 2

confused Buzzards Bay STEM teacher: analogRead(A0)

PostPosted: Wed Jul 26, 2017 5:43 am
by bradshawlupton
Board Setup and under test:
FullSizeRender-1.jpg
Setup:

very simple script

// Bradshaw Lupton BBSTEMA@piRshared.com
// Buzzards Bay STEM Academy 2017

int counter = 0;

void setup() {
Serial.begin(9600); delay(6000); yield();
Serial.println("adc test");
/* Initialize the ADC pin as an input. */
pinMode(A0, INPUT);
}

void loop() {
Serial.print("Yellow board LDR value = ");
Serial.print(analogRead(A0));
Serial.print(" count=");
Serial.println(counter++);
delay(500);
}



Crummy output, in a dark room, bright LED flashlight,
Expected full range of numbers 0-1023.

Isn't it "always something?", probably good old, "user" error.

adc test (nearly black room, shining bright flashlight on the LDR)
Yellow board LDR value = 3 count=0
Yellow board LDR value = 3 count=1
Yellow board LDR value = 3 count=2
Yellow board LDR value = 3 count=3
Yellow board LDR value = 2 count=4
Yellow board LDR value = 3 count=5
Yellow board LDR value = 3 count=6
Yellow board LDR value = 3 count=7
Yellow board LDR value = 2 count=8
Yellow board LDR value = 9 count=9
Yellow board LDR value = 9 count=10
Yellow board LDR value = 9 count=11
Yellow board LDR value = 9 count=12

Re: confused Buzzards Bay STEM teacher: analogRead(A0)

PostPosted: Wed Jul 26, 2017 7:10 pm
by icons
I would start by measuring the voltage on pin A0 with a multimeter, while covering the LDR with something and while exposing LDR to light. That way I would know for sure if it is hardware or software.
* very curious what does the chicken do?

Re: confused Buzzards Bay STEM teacher: analogRead(A0)

PostPosted: Wed Jul 26, 2017 7:45 pm
by rudy
Also consider that the spectral output of the flashlight might not match the spectral sensitivity of the LDR.

http://lednique.com/opto-isolators-2/li ... istor-ldr/

Re: confused Buzzards Bay STEM teacher: analogRead(A0)

PostPosted: Wed Jul 26, 2017 8:55 pm
by bradshawlupton
rudy wrote:Also consider that the spectral output of the flashlight might not match the spectral sensitivity of the LDR.

http://lednique.com/opto-isolators-2/li ... istor-ldr/


Thank you, the same flashlight worked great using nodemcu 1.0 firmware and a simple lua script. I seem to be having trouble with my arduino-esp8266 IDE coding. I tried three of the yellow development boards and got the same inconsistent, basically no LDR adc value change with any of them. I tried the yellow development board software from github, and got the same poor reading. Thanks for the spectral information, that is really neat too. I also taught physics.