Skip to main content

FemEng - Mini Light Controlled Curtains

This article is part of the FemEng Technical Workshop series.

I am a third-year Mechatronics student and this year I have been a part of the technical team workshop with FemEng and Grass Roots. We were each given a sidekick basics kit (174-3223) and an Arduino Uno (715-4081) to play around with for a few months and learnt a lot from tutorials made for us by the FemEng technical convener Natalia. After learning the basics of Arduino and how to use the different parts of our kits we had to do our own individual projects.

I decided to create some curtains to help me wake up in the morning by having them opening automatically when enough light is detected from a sensor. Originally, I planned to have the Arduino open my actual curtains but then they fell off the wall (we love student flats!), so instead I decided to make a smaller scale model and have a curtain open and close over my laptop window. However, after realising the servo motor only turned through 180° I again made it smaller and decided to have a curtain just open and close over a picture of a window on my laptop screen.

To begin with, I went back through the FemEng tutorials and looked at the circuitry and code used to implement the photocell and servo motor. The photocell is a kind of light-dependent resistor that varies its resistance depending on the brightness of the light over it and when connected to the analog input on the Arduino, the Arduino can convert this analog signal to a digital one. After setting up my circuit with both the motor and photocell I was unsure if it would fully work so I found this project on that required the same components just coded for a different purpose. I then adjusted a couple of things in my original set up like attaching the breadboard to 3.3V and the servo to 5V and I was ready to begin coding.

Electronics Setup from Instructables

electronic setup including Arduino

For the code, I set up the initial variable for the photocell output as well as importing the servo library and set that up. I then had to test what values the photocell was outputting when it was dark vs when it was light. At first, I had it in values of 0 to 1023 but then realised that by mapping it to 0 to 179 I got much easier controlled values at a better range. To see these values I used the serial monitor function and looked at what the brightness changed to when I had my finger covering the photocell and when I removed it. I found that when covered, the photocell outputted 12. I then set up the if loops for the determined photocell output values (<=12 and >=13) and had the servo move to 179° for one and 0° for the other. I also added a delay at the end of each of the loops to allow the curtains time to close before testing for the next brightness level. I hit some snags with the syntax for the if loops as I wasn’t used to the Arduino language and found some Arduino forum code that someone had been developing to open their blinds through a similar method. Their code was more complex than what I was looking for but it helped me realise how and where mine was going wrong and it was also useful seeing their questions to other people which better-explained issues I was also having.

#include <Servo.h>
int sensorValue = 0;
Servo servo1;
void setup() {
void loop() {
 Serial.print("Brightness = ");
 sensorValue = analogRead(A0);
 sensorValue = map(sensorValue, 0, 1023, 0, 179);
 if (sensorValue <= 12){
 else if (sensorValue>= 13){

Finally, I had to set up the actual curtain. Funnily enough, this bit ended up causing me the most headaches as when trying to find all of the components in my room, I had to get creative. I used a chopstick as my curtain rail with some bent decoration hooks as the loops to attach the curtain to the rail. I cut up an old t-shirt to make the curtain itself and held the set up on my laptop by holding the chopstick with two clips and then balancing them on a box behind. I then placed a further smaller box on top and using a hair clip held the motor in place above the rail. The entire thing was stuck together with ALOT of sellotape and although not the prettiest set up it works! I had many problems trying to get the motor to pull the curtain the right amount using a little piece of string tied between the arm and the end curtain hoop, but by sellotaping a long piece of lego to the end I made the arm long enough to sufficiently pull the curtain across the small portion of my screen where I had a picture of a little window set up that I could switch between night and day for effect.

Curtain rail and motor setup

In the videos below you can see the final product that operates with the lamp being switched on and off. In the future I would like to scale this project and actually implement it in my room (if I ever get my curtains back), I’d just need a bigger motor and maybe one that could rotate through 360° as well as something stronger than thread to pull the curtain along!

I am a 3rd year Mechatronics Engineering student
DesignSpark Electrical Logolinkedin