0

UPDATE: If I could I'd downvote myself. I'm a web developer and as I see that my job will be eaten, I'm trying to expand my skill set. Sometimes I wish I had a second pair of eyes or https://en.wikipedia.org/wiki/Rubber_duck_debugging


Previously I was asking which sensor use to measure the light: Which sensor to detect light?

Here is a short video showcasing my issue: https://www.youtube.com/watch?v=VGs_Ax_wlbg

Super simple .INO sketch from https://tkkrlab.nl/wiki/Arduino_KY-018_Photo_resistor_module

int sensorPin = A5; // select the input pin for the potentiometer
int ledPin = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}
void loop() {
  sensorValue = analogRead(sensorPin);
  digitalWrite(ledPin, HIGH);
  delay(sensorValue);
  digitalWrite(ledPin, LOW);
  delay(sensorValue);
  Serial.println(sensorValue, DEC);
}

I'm worried that my sensor readings are pretty much the same - in shade, brighten up by green laser...

Am I doing it right?

Are values from the sensor in the expected range?

Alternatively: is there any more sensitive sensor I should buy that will tell me more reliably if the there is green laser light pointing at it?

3
  • 1
    It helps if you plug the sensor into ANALOG 5, not into DIGITAL 5 ...
    – Majenko
    Oct 9, 2016 at 22:33
  • :) It helps... Thank you for being second pair of eyes and sanity check here! Oct 11, 2016 at 2:41
  • Could you place a filter on the sensor to block out the non green light? What are the values you are getting and what do you think they should be? Oct 11, 2016 at 12:27

1 Answer 1

1

***** ITS ANALOG 5 not DIGITAL 5 *****

Also try doing this:

delay(sensorValue*10);

The times 10 will help show the differences between each value.

3
  • It looks like he is using an LDR breakout. Those probably already have a resistor.
    – Gerben
    Oct 10, 2016 at 11:29
  • True, my bad. There is a 10k k smd tinynynynyny resistor on it. No external resistor needed.
    – Dat Ha
    Oct 10, 2016 at 11:32
  • OMG! ANALOG... So silly, that's why I need second pair of eyes (and some common sense)... Oct 11, 2016 at 2:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.