Use Arduino to control my curtains

Inspiration

Living in Greece I always had to open and close my curtains everyday since it was always sunny. Since I had recently ordered an arduino I was questioning whether it would be possible to have a button that automatically closes and opens the curtains. Unfortunately I was not able to start the project since I couldn't find a way to implement it. Fast forward 4 years later and I decided to revise the idea in the uk.

Problems
1st Problem

My bedroom in Greece had 1 window with 1 big curtain.

(Image below for reference)

My Bedroom in the UK has 2 windows with 2 curtains each.

(Image below for reference)

That meant that with 1 motor I would have to move 4 curtains in different directions. Using the above image as a reference lets number the curtains 1,2,3 and 4 from left to right. When closing the curtains, curtains 1 and 3 would have to move to the right and 2 and 4 to the left.

2nd Problem

Limited by the property and my budget. Since the building was a rental I didn’t want to drill the wall or ruin the curtain rail therefore the result should be as simplified as possible.

Solutions
Solution to problem 1

After a bit of thinking I came up with an idea including pulleys. A String passing through a pulley would be moving both directions. For example using the diagram below for reference, point A will be moving to the left and point B be to the right.

By using 4 pulleys and 2 motors we can control both curtains at the same time.

 

By turning the rope anticlockwise the curtains would close and clockwise to open.

 

So each window would look like this where the gears represent the pulleys and dots connections.

Solution to problem 2

To simplify we can connect the 1st and 3rd curtains to the top of the belt  and the 2nd and 4th curtains to the bottom. The curtains will close when the pulley is spinning clockwise and open when it spins anticlockwise. That way we only need 1 motor to move both sets of curtains.

Diagrams

Circuit Diagram

Physical Circuit

The circuit's job is to simply turn a motor constantly in one direction till the button is pressed at which point the direction of the motor would change. The other button is an on/off switch. The potentiometer was added just in case I wanted to control the motor’s speed.


 

Unfortunately I wasn't able to install it on my curtains since I couldn't think of an inexpensive way to install pulleys next to my curtain rods without drilling the wall. But it's a project I would definitely like to revise in the future.

 

Future Improvements

 

In the future I would like to improve the project and add more features. To begin with, I would like to be able to control the motor without buttons. Using a bluetooth device or Wi-Fi through IFTTT so I can Use voice commands to control my arduino. I would also like to replace the analogue potentiometer with a digital one so I can change the speed wirelessly.

Arduino Code

const int controlPin1 = 2;// the control pins will carry the logic - direction to turn and applied to the H-Bridge

const int controlPin2 = 3;

const int enablePin = 9; // attached to the pin EN

const int directionSwitchPin = 4;// 4 and 5 carry the values of buttonSwitches

const int onOffSwitchStateSwitchPin = 5;

const int potPin = A5; // analog signal, because it is a potentiometer delivering continuous values

int onOffSwitchState = 0;

int previousOnOffSwitchState = 0;

int directionSwitchState = 0;

int previousDirectionSwitchState = 0;

 

int motorEnabled = 0;

int motorSpeed = 0;

int motorDirection = 1;

void setup() {

  pinMode(directionSwitchPin,INPUT);

  pinMode(onOffSwitchStateSwitchPin,INPUT);

  pinMode(controlPin1,OUTPUT);

  pinMode(controlPin2,OUTPUT);

  pinMode(enablePin,OUTPUT);

 

 

  digitalWrite(enablePin,LOW);// the motor initializes at OFF

}

void loop() {

  onOffSwitchState = digitalRead(onOffSwitchStateSwitchPin);

  delay(1);

  directionSwitchState = digitalRead(directionSwitchPin);

  motorSpeed = analogRead(potPin)/4;

 

  if(onOffSwitchState != previousOnOffSwitchState){ // this part allows the user to have the motor spin without having to hold the button itself. Otherwise we should keep pressing the button switch to turn the motor.  

    if(onOffSwitchState ==HIGH){ // if the user presses the button, the state changes. Otherwise, it remains unchanged.

      motorEnabled = !motorEnabled;

    }

  }

  if (directionSwitchState != previousDirectionSwitchState) { // analagous to OnOffSwitchState

    if (directionSwitchState == HIGH) {

      motorDirection = !motorDirection;

    }

  }

  if(motorDirection == 1){ // If the Direction is 1, turn left.

    digitalWrite(controlPin1, HIGH);

    digitalWrite(controlPin2, LOW);

  }

  else {  // If the Direction is 0, turn right.

    digitalWrite(controlPin1, LOW);

    digitalWrite(controlPin2, HIGH);

  }

 

  if(motorEnabled == 1) { // If the motor should be enabled, set EN to HIGH and the motorSpeed indicated by the Potentiometer

    analogWrite(enablePin, motorSpeed);

  }

  else {

    analogWrite(enablePin, 0); // If the motor is turned Off, set EN to LOW

  }

 

  previousDirectionSwitchState = directionSwitchState; // These lines are very important to keep the current state!

  previousOnOffSwitchState = onOffSwitchState;

}