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);
}
}