Automatic door opener

I have a motor and a ldr sensor I need the door to open one time in the morning and one time in the afternoon I need help with the code.

here is my code so far:

const int ledPin = 13;
#define CW 7
#define CCW 8
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(CW, OUTPUT);
pinMode(CCW, OUTPUT);
}

void loop() {
unsigned int AnalogValue;
AnalogValue=analogRead(A0);

if(AnalogValue <=250) //Night need to fix runs the same thing every 10 mins
{
digitalWrite(CW, LOW);
digitalWrite(ledPin, LOW);
Serial.println(“IT IS NIGHT”);
}

if(AnalogValue >=250)//Day need to fix runs the same thing every 10 mins
{
digitalWrite(CCW, HIGH);
digitalWrite(ledPin, HIGH);
Serial.println(“IT IS MORNING”);

}

}

gamzprism:
I need help with the code.

Please post the code you need help with and tell us in detail what it actually does and what you want it to do that is different. That way we can focus on the parts you need help with rather than wasting time on things that you can do.

If you just want someone to write a program for you please ask in the Gigs and Collaborations section and be prepared to pay.

...R

How do I make a variable that keeps track of how many times a motor is turned on and off

gamzprism:
How do I make a variable that keeps track of how many times a motor is turned on and off

What have you tried?

How much experience have you of Arduino programming, or any other type of programming?

It’s much easier to help when we can see how you are approaching the problem. A variable does not exist in a vacuum. There will be lots of other code.

…R

i have have coded in python before and i would see my self as intermediate but i have not coded in Arduino coding language before,

note the motor starts ever time the sensor detects if it is night or day i plan to use delay to make the sensor check the ldr every 10 mins which i can code fine i just need help making the motor run once when the ldr sensor detects light and one time again when it is dark

How do I get a my motor to run for a certain amount of time my code is above.

can You Try RTC. Set morning and afternoon time.

@gamzprism, you seem to have made a big change to your Original Post. Please don’t do that as it makes a nonsense of subsequent comments. Just post new material in a new Reply in the proper chronological order.

Also when posting code please use the code button </>

so your code 
looks like this

It makes it much easier to help you.

…R