arduino / Arduino

Arduino IDE 1.x
https://www.arduino.cc/en/software
Other
14.13k stars 7.01k forks source link

playground Learning PhotoResistor [imported] #1100

Closed cmaglie closed 11 years ago

cmaglie commented 11 years ago

This is Issue 1100 moved from a Google Code project. Added by 2012-11-05T22:47:15.000Z by igna...@turegano.it. Please review that bug for more context and additional comments, but update this bug.

Original labels: Type-Defect, Priority-Medium

Original description

What steps will reproduce the problem?

  1. take the code from http://www.arduino.cc/playground/Learning/PhotoResistor
  2. Put it in arduino
  3. led didn't works

What is the expected output? What do you see instead?

Led 11 bright when we have light, but it didn't works

Please provide any additional information below.

The solution is change

analogWrite(ledPin, analogRead(lightPin)/4); to digitalWrite(ledPin, analogRead(lightPin)/4);

and better pin13 ;)

shfitz commented 11 years ago

Not sure I see the issue with the code on the playground. Digital pin 11 is a PWM pin. Changing it to digitalWrite will just turn the LED on all the time.