Spencer RocheTyler Tufts
Published

Automatic Blinds System (MEGR 3171 Fall 2017 Project)

This project uses two particle photons to control the blinds in your house. Flip a switch and the blinds will open or close.

BeginnerFull instructions provided5 hours1,852
Automatic Blinds System (MEGR 3171 Fall 2017 Project)

Things used in this project

Hardware components

Photon
Particle Photon
×2
Slide Switch
Slide Switch
×2
Adafruit battery holder
×1
Futaba Servo Motor
×1
Breadboard (generic)
Breadboard (generic)
×2
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Maker service
IFTTT Maker service
Google Sheets
Google Sheets

Hand tools and fabrication machines

screw driver
wire cutters

Story

Read more

Schematics

Switch Photon (Publisher)

This Photon sends the publish code when the switch is slid to open or close the blinds. An external power source using an Apple USB adapter was used to power the photon.

Servo Photon

This photon is subscribed to the first, and upon receiving a single turns the servo motor clockwise or counter clockwise depending on desired blind location. An external power source using an Apple USB adapter was used to power the photon.

Code

Switch Photon

C/C++
This code publishes an open or closed command depending on which switch is flipped. It also relays this data to the thing speak data log.
// These values below give variables to pin inputs
int led = D7;
int led1 = D6;
//The setup section below configures the pins as inputs
void setup() {
pinMode(led,INPUT);
pinMode(led1,INPUT);
}
//The loop below reads the pin input and publishes 
//the "data" to the cloud so that the other photon can subscribe to it
//The System.sleep keeps the loop from only publishing once to the cloud
void loop() {
if (digitalRead(led)==HIGH){
    String Blindz_UNCC=String(10);
    Particle.publish("Blindz_UNCC","BlindzOpen",PUBLIC);
    delay(2000);
    System.sleep(40);
}
else if(digitalRead(led1)==HIGH){
    Particle.publish("Blindz_UNCC","BlindzClosed",PUBLIC);
    delay(2000);
        System.sleep(40);
}
else{}

}

Servo Photon

C/C++
This code includes the particle subscribe information to receive the signals from the switch photon. Upon receiving the signal it determines if it is an open or close signal and turns the servo motor accordingly.
Servo myservo;
void setup() {
//the line of code below publishes to the event that the other particle photon published
Particle.subscribe("Blindz_UNCC", myHandler);


}

//The code below actuates the servo in either the clockwise direction or the counter-clockwise direction
//to actuate the blinds
void myHandler(const char *event, const char *data)
{

 if (strcmp(data,"BlindzOpen")==0) {
myservo.attach(D0);
myservo.write(110);
delay(4700);
myservo.detach();
}
 if (strcmp(data,"BlindzClosed")==0) {
myservo.attach(D0);
myservo.write(70);
delay(4700);
myservo.detach();

}


}

Credits

Spencer Roche

Spencer Roche

1 project • 0 followers
Tyler Tufts

Tyler Tufts

1 project • 0 followers

Comments