DC motor control using ldr sensor Module

Hi,
What is the application of your program?

So the motor changes direction when you cover/uncover the LDR?
Just that it doesn't stop after 5 seconds.

You should be looking for when the LDR output CHANGES from light to dark, NOT when it is light or dark.

Tom... :grinning: :+1: :coffee: :australia:

I think you should connect "ENA" and "ENB" pins to the "PWM" pins of the UNO board and try setting the speed of the motors.

And also try this code this may not work...

//CW defining clock wise
//ACW defining anti-clock wise
#define CW 10;
#define ACW 11;

void setup()
{
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
Serial.begin(9600);
}

void loop()
{
int in = analogRead(A0);
//coming to if statements
if (in <= 30)
{
digitalWrite(10, HIGH);
}
else
{
digitalWrite(10, HIGH);
delay(5000);
digitalWrite(10, LOW);

}
if (in >= 30)
{
digitalWrite(11, HIGH);
}
else
{
digitalWrite(11, HIGH);
delay(5000);
digitalWrite(11, LOW);

}
}

I am using it for automatic roller curtain when it will be be under the exposure of sun it should close the curtain and the curtain takes 10 sec to close or open the curtain.

Hi,

Relying on a timer to open and close curtains is a bit hit and miss.
You should have limit switches to indicate fully open and fully closed.

If you leave or someone moves the curtains to half open, then a fixed time in either direction will try to over drive your curtains and stress your motors and controller.

You would also need some form of manual control to operate the curtains when it is dark or sunny.

Have you tried to see if the motor/gearbox and motor controller can do the job?

Tom... :grinning: :+1: :coffee: :australia:

How i can do that i am not much familiar with arduino programs.

I have already tried this code. This will not work.

I know this situation can occur but first, I want the first part complete can you help me with that code I am not much familiar with Arduino.

When LDR is exposed to sun its value is less tan 30. It should be able to rotate the motor for 5 sec irrespective, for how much time it is exposed to sun.

can you guide me about the switch conditions how I can use them?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.