I guess many people prefer sitting by the window in the office, they can enjoy the beautiful scenery outside and pleasant sunshine during cold winter. However, they have to pull the curtain down when the light is too strong, especially in summer. So pulling up and down the curtain becomes a daily task, sometimes it is really anoying.
Hardware used for this project:
List of hardware:
1. Romeo-All in one Controller(DFR0004)
3. Adjustable Infrared Sensor Switch (SEN0019)
4. DC motor (12V- FIT0493, FIT0277)
5. 12V power adapter
6. Servo extension cable 300mm(FIT0033)
7. DC Barrel Jack Adapter-Male/Female(FIT0110/ FIT0151)
8. Misc. mechanical parts
First of all, the original curtain should be modified.A gear was designed which can perfectly match the pattern of beads on the chain which moves the curtain up and down. A DC motor with speeds of 120 r/min is used to drive the gear. The drive assembly is tightly fixed to the wall.
#include <IRremote.h> const int InfraredSensorPin1 = 7; const int InfraredSensorPin2 =8; int RECV_PIN = 11; int E1 = 5; //M1 Speed Control int M1 = 4; //M1 Direction Control IRrecv irrecv(RECV_PIN); decode_results results; void setup() { pinMode(InfraredSensorPin1,INPUT); pinMode(InfraredSensorPin2,INPUT); pinMode(M1, OUTPUT); pinMode(E1, OUTPUT); Serial.begin(9600); irrecv.enableIRIn(); // Start the receiver } void loop() { if(digitalRead(InfraredSensorPin1) ==LOW&&digitalRead(InfraredSensorPin2) ==LOW) { digitalWrite(E1,LOW); if(results.value==0xFD807F) { analogWrite (E1,255); digitalWrite(M1,LOW); } delay(1000); } if(digitalRead(InfraredSensorPin1) ==HIGH&&digitalRead(InfraredSensorPin2) == HIGH) { digitalWrite(E1,LOW); if(results.value==0xFD906F) { analogWrite (E1,255); digitalWrite(M1,HIGH); } delay(1000); } if (irrecv.decode(&results)) { Serial.println(results.value, HEX); if(digitalRead(InfraredSensorPin1) ==LOW&&digitalRead(InfraredSensorPin2) ==HIGH) { if(results.value==0xFD807F) { analogWrite (E1,255); digitalWrite(M1,LOW); } if(results.value==0xFD906F) { analogWrite (E1,255); digitalWrite(M1,HIGH); } if(results.value==0xFDA05F) { digitalWrite(M1,LOW); analogWrite (E1,0); } } irrecv.resume(); // Receive the next value } }