automated blinds

Hey everyone, I have some experience with python and using it for network security purposes. I am trying to use that knowledge to knock the dust off my old c++ coding brain. Anyways I am trying to make automated blinds. What I would like for them to do is either run the dc motor for X amount of time or X amount of rotations. I would rather not have to use the rotation as I am aware I would need something to help track the rotations. I would like to program the Arduino to run the sequence for " X amount of seconds" to the point it reaches the open position (given that I will adjust run times accordingly). Then I would like to run the motor in reverse with the same effect, just to the closed position. The motor is setup and runs both directions I just do not know how to implement "run time" into my code. The end game is for this to connect to google home using a Esp8266 and adafruit and IFTTT to make triggers to open and close the blinds. I get bored fairly easy so I cant help trying to make something instead of buying it!! Here is my script below and a layout of my connections with the arduino, I hope someone can guide me in the correct direction!

/*
automated blinds
*/

int enablePin = 11;
int in1Pin = 10;
int in2Pin = 9;
int switchPin = 7;
int potPin = 0;
int motor1speed = 10;
int motorPin1 = 9;
long int stop1;

void setup()
{
 stop1 = millis()+3000; // 3sec
 pinMode(in1Pin, OUTPUT);
 pinMode(in2Pin, OUTPUT);
 pinMode(enablePin, OUTPUT);
 pinMode(switchPin, INPUT_PULLUP);
}

void loop()
{
int speed = analogRead(potPin) / 4;
 boolean reverse = digitalRead(switchPin);
 setMotor(speed, reverse);
 
}

void setMotor(int speed, boolean reverse)
{
 analogWrite(enablePin, speed);
 digitalWrite(in1Pin, ! reverse);
 digitalWrite(in2Pin, reverse);
}

Please read the forum guide in the sticky post, then modify and correct your post above.


Useless diagram, too fuzzy to read component values or pin numbers. But what I can see, or rather not see, is an external power supply for the motor. You can't run a motor off usb power, more current will be needed.

how do I add the image into the post?

Also sorry what part of the post needs to be modified so I can make sure to change it. Also I do not have a external power supply and let me see if I can get a better picture of the layout, I was thinking of either using a battery or trying to find a way to be able to plug it into a wall. This is going to sit inside a custom made shroud hiding all of the hardware my only concern with using a battery is life expectancy of the battery. Do you think it would consume to much power to use a battery?

Like this.

But first make a readable image. Preferably a proper schematic diagram. You can use the "Schematic view" in Fritzing, or any other schematic editor tool you may have. Or hand drawn on paper is also perfectly acceptable if you keep it neat.

what part of the post needs to be modified

A few aspects need attention. Read the forum guide and it should become clear.

This image should be more clear, and I can also draw one up tomorrow showing where everything connects to the L293D

Thanks for adding the code tags to your original post. +1 Karma. But is that all you changed? What other advice from the forum guide did you miss? Some specs or a link to the specs of the motor, for example?

Your motor needs enough torque to move the blinds, and so might draw quite a lot of current, especially when stalled. To work out of batteries will be a suitable part source, you will need to know or estimate the typical current draw under load and the seconds of running time per day that will be needed.