Good evening.
I am looking to turn on an LED, with a couple second delay, then turn it off. While this is happening, I am also wanting to turn a servo 45 degrees, then return to 0 once the delay is done. Any help would be appreciated. Thanks
/*
ARDUINO LIGHT SENSOR CONTROLS LED
By: TheGeekPub.com
More Arduino Tutorials: https://www.thegeekpub.com/arduino-tutorials/
*/
// constants won't change
const int LIGHT_SENSOR_PIN = A0; // Arduino pin connected to light sensor's pin
const int LED_PIN = 3; // Arduino pin connected to LED's pin
const int ANALOG_THRESHOLD = 500; // this sets the the threshold for when the LED turns on.
// variables will change:
int analogValue;
void setup() {
pinMode(LED_PIN, OUTPUT); // set arduino pin to output mode
}
void loop() {
analogValue = analogRead(LIGHT_SENSOR_PIN); // read the input on analog pin
if(analogValue < ANALOG_THRESHOLD)
digitalWrite(LED_PIN, HIGH); // turn on LED
else
digitalWrite(LED_PIN, LOW); // turn off LED
}
Is this not the time to mention the posted sketch does not match the description?
The posted sketch has a photo resistor turn an LED on when light is bright and off when light is not bright... and I think that is backwards. My lights turn on in the dark and turn off in the light.