LDR motor control

I am trying to control a geared motor with an LDR such that when it is bright the motor turns clockwise and anti-clockwise when it is dark. This is for an automated blind. Any help would be great

We need some additional information.
Post your sketch, well formated, with well-tempered comments and in so called
code tags "< code >" and a detailed circuit diagram to see how we can help.
Have a nice day and enjoy coding in C++.

On the WEB, looking... find

" geared motor with an LDR - Google Search

What have you done, so far?

You're going to need something called an "H-bridge". This does two important things. First, it handles the high currents drawn by motors, which the Arduino's pins cannot. Secondly, it can send the current through the motor in either direction, causing the motor to run forwards or reverse.

Probably the simplest way to make an H-bridge is to use a pair of SPDT relay modules commonly sold for use with Arduino. You may have some of these.

Better is an H-bridge module. Many of the common types use the rather old design L293 or L298 chips. These are not great but may be ok if you have one already.

Even better are more modern design H-bridge modules that use MOSFET drivers.

The forum can suggest a suitable H-bridge for you, but only once we know the specs of the motor (voltage, typical current, stall current).

Also, you aren't going to want to turn the motor forever when it is dark, right? You'll want to detect when it's dark to close the blinds and then detect when it's light to open the blinds. But at some point you'll have to stop when the blinds reached their fully closed or open position. Have you determined what type of feedback you're going to use to determine when it's time to stop moving the motor?

I have decided to change to a continuous servo motor to prototype the project first and have the following code:

#include <Servo.h>

//create a servo object called servo1

Servo servo1;

// create a variable called lightValue to read the value from the voltage divider.

int lightValue;

void setup() { // put your setup code here, to run once:

// initialize serial communication at 9600 bits per second:

  Serial.begin(9600);

// set the servo pin, pin 9, as an servo output pin

servo1.attach(9);

}

 void loop() { // put your main code here, to run repeatedly:

lightValue = analogRead(A0);

// map the light readings to the angle possible by the servo motor

lightValue = map (lightValue, 45, 15, 0, 180);

// control the servo motor based on the light value read, adjust linearly by angles

servo1.write (lightValue);

// print out light sensor value

Serial.println(lightValue);

}

Was thinking of a pressure switch to stop but not sure. Also not sure how to adjust the speed of the servo.

I had thought of putting in a switch similar to ones used in 3d printers, just not sure. What would you recommend?

For simplicity and for a one of circuit, suggest two SPDT relays for the motor control.

However, before proceeding, create a schematic of what you think the final circuit will look like; can be change as you advance thru this process.

Here is a start:

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