01/08/2017
IntelligentCurtainsProject
Objective:
Thepurposeoftheprojectistobuildacurtainthatisstimulatedbytheintensityof
thelight.Thecurtainwillbecontrolledbyamotor,atthedaytimethemotorwill
openthecurtainandatnightitwillbeclosed.
Equipment:
- ArduinoUNO
- MotorShield
- StepperMotor
- LDRphotoresistor
- 1kand10ohmresistance
- LED
- Wires
Details:
Inourprojectthestandardunits(voltages)forLEDlightatdaylightandmoonlightare
235(1.14V)and320(1.56V)respectively.Whenthearduinoreadsaninputunitlower
than310,itwillsendsquarewavewithspecificdutycycle(speed)tooperatethe
steppermotorandopenthecurtain,ontheotherhand,itwillsendsignaltooperate
themotortoclosethecurtainiftheinputishigherthan350.
Code:
#include<AFMotor.h>//neededlibrarytocontrolsteppermotor
intldr=A0;//setanaloginputpin
intsensorValue;
inti=0;
intj=0;
AF_Steppermotor1(48,1);//setportofthesteppermotorand#ofrevolutionsper
minute
voidsetup(){
Serial.begin(9600);
pinMode(A0,INPUT);
voidloop(){
motor1.setSpeed(0);//setinitialspeedofthemotor
//readthevaluefromthesensor:
sensorValue=analogRead(ldr);//readtheanaloginput
Serial.print(sensorValue);
Serial.print("");
Serial.print(i);
if(sensorValue<235&&i<1){
motor1.setSpeed(700);//setthespeedofthemotor
motor1.step(48*150,FORWARD,DOUBLE);//set#ofstepsperrevolution,direction
andnumberofcoilsneededtobeused
i++;
j=0;
}
if(sensorValue>320&&j<1){
motor1.setSpeed(700);
motor1.step(48*150,BACKWARD,DOUBLE);
j++;
i=0;
}
}