LDR - Figure 5-5 Example 2 - Need Help

Hi Guys (im a super newb so bare with me),

I'm on page 61 on Getting Started with Arduino 2nd Edition, and I'm having a bit of trouble with the LDR resistor.

I grabbed the code from Example 02 and I followed the directions in putting it together using the 10k resistor (Brown Violet Orange and Gold)

After hooking everything up I put my hand over it and nothing happens the light stays on, I know you guys are experts and I'm sorry to bother you guys with this newbie question what am I doing wrong?

Thanks guys for reading and helping out,

Best Regards,

David O

Code just in case

// Example 02: Turn on LED while the button is pressed

const int LED = 13; // the pin for the LED
const int BUTTON = 7; // the input pin where the
// pushbutton is connected
int val = 0; // val will be used to store the state
// of the input pin

void setup() {
pinMode(LED, OUTPUT); // tell Arduino LED is an output
pinMode(BUTTON, INPUT); // and BUTTON is an input
}

void loop(){
val = digitalRead(BUTTON); // read input value and store it

// check whether the input is HIGH (button pressed)
if (val == HIGH) {
digitalWrite(LED, HIGH); // turn LED ON
} else {
digitalWrite(LED, LOW);
}
}

Hi Guys,

I figured it out,

sorry for bothering everyone.

Hello,

I am having the same problem. How were you able to resolve?

craftandcurio:
Hello,

I am having the same problem. How were you able to resolve?

Hi Craft,

Here's how I got it,

I was surfing the web after posting this and someone on youtube was in depth about this certain project.

The light sensitivity is the issue.

Copy and paste the code, then follow the video and when he mentions light sensitivity play close attention to that part with the monitor and set it by the lighting in your room, so if it's at 460 put it below that.

Happy Hacking,

David