WillChase HavelyGreg Wycoff
Published

MEGR 3171 - Automatic Blinds

A set of blinds that will open automatically when sunlight hits a photodetector as well as open and close at a certain time.

IntermediateShowcase (no instructions)200
MEGR 3171 - Automatic Blinds

Things used in this project

Hardware components

Argon
Particle Argon
×3
Capacitor 100 µF
Capacitor 100 µF
×1
Driver DRV8825 for Stepper Motors for Theremino System
Driver DRV8825 for Stepper Motors for Theremino System
×1
Photo resistor
Photo resistor
×1
Resistor 220 ohm
Resistor 220 ohm
×1
P Series Nema 23 Stepper Motor
×1

Software apps and online services

Maker service
IFTTT Maker service
Google Sheets
Google Sheets
Particle Build Web IDE
Particle Build Web IDE

Story

Read more

Custom parts and enclosures

Bearing Housing

A housing used to hold the bearing on the side opposite the motor.

Motor in Housing

Blinds set up

Schematics

Sun detector Schematic

Motor Schematic

Code

Timer

C/C++
The code for the Timer. This is formatted to publish an event called 'Morning' when the argon picks up the daylight event and then to publish an event called 'Night' at a certain time. This code can be changed by changing the time to preference as well as adjusting time zone based on UST.
void setup() {
    
    Particle.subscribe("daytime",open,"e00fce68bc2298d8053ed7ba");

    Time.zone(-4.00);
    Serial.begin(9600);

    delay(1000);
}

void open(const char *event,const char *data)
    {
        Serial.print(Time.timeStr());
    
    
        if (Particle.subscribe("daytime",open,"e00fce68bc2298d8053ed7ba")){ 
            delay(1000);
            Particle.publish("Morning","On",PUBLIC); 
            Particle.unsubscribe();                          
            delay(1000);                                                        
        
        }
    }
    
void loop () {
    if (Time.hour() == 21 && Time.minute() == 00 && Time.second() == 00){
        Particle.publish("Night","On",PUBLIC);                           
        delay(1000);                                                             
        Particle.publish("Night","Off",PUBLIC); 
    }

}
    

Sunlight Detector

C/C++
The code for the photoresistor. This code constantly publishes events depending on if it detects light or not. If light is detected an event called 'daytime' starts and if no light is detected the event called 'nighttime' is published. This code can be adjusted with the value of resistance needed for your specific photoresistor.
int led2=D7;
int photoresistor = A0;
 
int analogValue;
 

void setup() {
    pinMode(led2,OUTPUT);
  pinMode(photoresistor, INPUT);
   Particle.variable("photoresistor", analogValue);
   

}
void loop() {
    delay(1000);
  analogValue = analogRead(photoresistor);
  
  if (analogValue >50){
      
      digitalWrite(led2, HIGH);
      Particle.publish("daytime","It's a sunny day!",PRIVATE);
  }
 
else{ 
    digitalWrite(led2,LOW);
    Particle.publish("nighttime","It's nighttime", PRIVATE);
}}

Motor

C/C++
#define dirPin D2
#define stepPin D3
#define stepsPerRevolution 200
void setup() {
  // Declare pins as output:
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
  
  Particle.subscribe("Morning",open,"e00fce68e6de1bfbcd25e162");
  Particle.subscribe("Night",close,"e00fce68e6de1bfbcd25e162");
  
  
}
        void open(const char *event,const char *data)
{
         
         
         if (Particle.subscribe("Morning",open,"e00fce68e6de1bfbcd25e162"))
         delay(1000);
        digitalWrite(dirPin, HIGH);
         for (int i = 0; i < 5000; i++) {
         
                digitalWrite(stepPin, HIGH);
                 delayMicroseconds(500);
                digitalWrite(stepPin, LOW);
             delayMicroseconds(900);
             
       
       delay(1000);
         }
   
}
        void close(const char *event,const char *data)
{
         
        
         if (Particle.subscribe("Night",close,"e00fce68e6de1bfbcd25e162"))
       delay(1000);
        digitalWrite(dirPin, LOW);
         for (int i = 0; i < 5000; i++) {
         
                digitalWrite(stepPin, HIGH);
                 delayMicroseconds(500);
                digitalWrite(stepPin, LOW);
             delayMicroseconds(900);
             
       
       delay(1000);
         }
   
}

Credits

Will

Will

1 project • 0 followers
Chase Havely

Chase Havely

1 project • 2 followers
Greg Wycoff

Greg Wycoff

1 project • 1 follower

Comments

Add projectSign up / Login