Hello. I am going through the GETTING STARTED WITH ARDUINO book and there is an example using a Light Sensitive Resistor and inputing that info into an analog pin to vary an LED brightness.
When I do the sketch, the LED only varies slightly. I would like it to go all the way out and back up if possible.
Here is the code Im using, directly from the book:
// Example 06B: Set the brightness of LED to
// a brightness specified by the
// value of the analogue input
const int LED = 10;
int val = 0;
// the pin for the LED
// variable used to store the value
// coming from the sensor
void setup() {
pinMode(LED, OUTPUT); // LED is as an OUTPUT
// Note: Analogue pins are
// automatically set as inputs
}
void loop() {
val = analogRead(0); // read the value from
analogWrite(LED, val/4); // turn the LED on at
// the sensor
// the brightness set
// by the sensor
delay(10); // stop the program for
}
// some time
ANY HELP APPRECIATED