Daniel MidgetteJacob BurwellPatrick Kennedy
Published

Fully Automated Blinds

The best way to save electricity from using your light bulbs is to open your blinds and let the sun shine through!

IntermediateShowcase (no instructions)8 hours199
Fully Automated Blinds

Things used in this project

Hardware components

Photon
Particle Photon
×3
Dual H-Bridge motor drivers L298
SparkFun Dual H-Bridge motor drivers L298
L298N
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×3
12V DC Motor
Jacobs Motor
×1
3 V DC Motor
×1
Command Strips
×2
Electrical Tape
×1
Male to Male Solid 22 AWG Wire
×15
Solder and Solder Iron
×1
Resistor 220 ohm
Resistor 220 ohm
×2
Magnetic Sensors
×1

Software apps and online services

Blynk
Blynk
Maker service
IFTTT Maker service
Google Sheets
Google Sheets

Story

Read more

Schematics

IOT Schematic

Iot u5vzgmxh8c

Code

Tilt Blinds Code (Daniel)

C/C++
// This #include statement was automatically added by the Particle IDE.
#include <blynk.h>
#define BLYNK_PRINT Serial
const int pot_input = A1;
bool dir1 = HIGH;
bool dir2 = HIGH;
bool dir3 = HIGH;
char auth[] = "bbc7bb8ca4be4499af3306e7c928ae62";



void setup() {
  Serial.begin(9600);
  delay(5000); // Allow board to settle
  Blynk.begin(auth);
  pinMode(D1, OUTPUT);  /* Motor control pin 1 */
  pinMode(D7, OUTPUT); /*turns D7 LED on*/
  pinMode(D6, INPUT);
  pinMode(D2, OUTPUT);  /* Motor control pin 2 */
  pinMode(D3, OUTPUT);  /* PWM pin for Speed Control */ //goes to enable or pwm input of H bridge
  pinMode(D4, INPUT_PULLUP);  /* Interrupt pin for direction control */ //mag switch 1 - other side to gnd
  attachInterrupt(D4, motorfwd, FALLING);  /* Interrupt on falling edge on pin 2",  */
  pinMode(D5, INPUT_PULLUP);  /* Interrupt pin for direction control */ //mag switch 2
  attachInterrupt(D5, motorrev, FALLING);  /* Interrupt on falling edge on pin 2 */
  Particle.subscribe("Blinds_Open1234", Blinds_Open, "42004c001051363036373538"); // jacob
  Particle.subscribe("Blinds_Tilt_Close",Tilt_Open,"230026000c47363433353735"); //patricks
}
BLYNK_WRITE(V1) {
    if (param.asInt() == 1) { // On button down...
        // Tweeting!
        // Note:
        //   We allow 1 tweet per minute for now.
        //   Twitter doesn't allow identical subsequent messages.
        Blynk.tweet("My Particle project is tweeting using @blynk_app and it’s awesome!\n @Particle #IoT #blynk");

        // Pushing notification to the app!
        // Note:
        //   We allow 1 notification per minute for now.
        Blynk.notify("You pressed the button and I know it ;)");
        if (digitalRead(D6) == HIGH){
      Particle.publish("Tilt_Open12", "h", PUBLIC);
  }
    }
}

BLYNK_WRITE(V2) {
    int r = param[0].asInt();
    int g = param[1].asInt();
    int b = param[2].asInt();
    if (r > 0 || g > 0 || b > 0) {
        RGB.control(true);
        RGB.color(r, g, b);
    } else {
        RGB.control(false);
    }
}

void motorcontrol() {
  int pwm_adc;
  pwm_adc = analogRead(A1); /* Input from Potentiometer for speed control */
  ;digitalWrite(D1,dir1);
  delay(1000)
  ;digitalWrite(D2,dir2);
  delay(1000)
  ;analogWrite(D3, pwm_adc / 4);    
}

void motorfwd(){
  //stop and go fwd
  delay(1000);
  D1 == HIGH;
  D2 == LOW;
  analogWrite(D3,0); 
;} 

void motorrev(){
    //stop and rev
    D1 == LOW;
    D2 == HIGH;
  delay(2000); //This number can be whatever works best for the system
  //D1 = !D1;
  //D2 = !D2;
  ;delay(200)
;} 

void moveblinds(){
    //do control signals to move motor
    analogWrite(D3,120); //number determines pwm effort.  1024=max?
}

void Blinds_Open(const char *event, const char *data){
    digitalWrite(D7,HIGH);
}
void Tilt_Open(const char *event, const char *data){
      digitalWrite(D7,HIGH);
}
void Patrick(const char *event, const char *data){
     digitalWrite(D7,HIGH);
}

void loop(){
     Blynk.run();
     if (digitalRead(D6) == HIGH){
      Particle.publish("Tilt_Open12", "h", PUBLIC);
      delay(500);
      digitalWrite(D7,LOW);
  }
  if (D1 == HIGH){
      Particle.publish("Tilt_Blinds","g", PUBLIC);
      delay(5000);
  } else if (D2 == HIGH){
      Particle.publish("tilt_close", "g" , PUBLIC);
      delay(5000);
  }
  delay(1000);

}

Open Blinds (Jacob)

C/C++
// This #include statement was automatically added by the Particle IDE.
#include <blynk.h>

#define BLYNK_PRINT Serial
const int pot_input = A1;
bool dir1 = HIGH;
bool dir2 = HIGH;
char auth[] = "1720598230864b55997f670821097f5f";
//bool swi4 = HIGH;
//bool swi5 = HIGH;

void setup() {
  Serial.begin(1000);
  delay(1000); // Allow board to settle
  Blynk.begin(auth);
  pinMode(D1, OUTPUT);  /* Motor control pin 1 */
  pinMode(D2, OUTPUT);  /* Motor control pin 2 */
  pinMode(D7, OUTPUT);
  digitalWrite(D7, LOW);
  pinMode(D3, OUTPUT);  /* PWM pin for Speed Control */ //goes to enable or pwm input of H bridge
  pinMode(D4, INPUT_PULLUP);  /* Interrupt pin for direction control */ //mag switch 1 - other side to gnd
  attachInterrupt(D4, motorfwd, FALLING);  /* Interrupt on falling edge on pin 2",  */
  pinMode(D5, INPUT_PULLDOWN);  /* Interrupt pin for direction control */ //mag switch 2
  attachInterrupt(D5, motorrev, FALLING);  /* Interrupt on falling edge on pin 2 */
  //Particle.subscribe("Open_Blinds", motorfwd);
  //Particle.subscribe("Close_Blinds", motorrev);
  Particle.subscribe("Open", open, "230026000c47363433353735"); //patricks
  Particle.subscribe("Tilt_Open12", Tilt_Open, "43002e000347363339343638"); //daniels

}

BLYNK_WRITE(V1) {
    if (param.asInt() == 1) { // On button down...
        // Tweeting!
        // Note:
        //   We allow 1 tweet per minute for now.
        //   Twitter doesn't allow identical subsequent messages.
        Blynk.tweet("My Particle project is tweeting using @blynk_app and it’s awesome!\n @Particle #IoT #blynk");

        // Pushing notification to the app!
        // Note:
        //   We allow 1 notification per minute for now.
        Blynk.notify("You pressed the button and I know it ;)");
    }
}

BLYNK_WRITE(V2) {
    int r = param[0].asInt();
    int g = param[1].asInt();
    int b = param[2].asInt();
    if (r > 0 || g > 0 || b > 0) {
        RGB.control(true);
        RGB.color(r, g, b);
    } else {
        RGB.control(false);
    }
}

void motorcontrol() {
  int pwm_adc;
  pwm_adc = analogRead(A1); /* Input from Potentiometer for speed control */
  ;digitalWrite(D1,dir1);
  delay(1000)
  ;digitalWrite(D2,dir2);
  delay(1000)
  ;analogWrite(D3, pwm_adc / 4);    
}

void motorfwd(){
  //stop and go fwd
  delay(1000);
  D1 == HIGH;
  D2 == LOW;
  analogWrite(D3,0);
  Particle.publish("Particle_Dudes_Patrick", "Open_Blinds", PUBLIC);
  if (digitalRead(D6) == HIGH){

      Particle.publish("Blinds_Open1234", "h");
  }
 } 

void motorrev(){
    //stop and rev
    delay(1000);
    D1 == LOW;
    D2 == HIGH;
    Particle.publish("Particle_Dudes_Patrick", "close_blinds", PUBLIC);
 } 

void moveblinds(){
    digitalWrite(D3, HIGH); //number determines pwm effort.  1024=max?
}

void open(const char *event, const char *data){
    digitalWrite(D7,HIGH); //tells if blinds are up
}

void close(const char *event, const char *data){
    digitalWrite(D7,HIGH);
}

void Tilt_Open(const char *event, const char *data){
   digitalWrite(D7,HIGH); // tilt is closed
}




void loop() {
    Blynk.run();  
   if (digitalRead(D6) == HIGH){
      Particle.publish("Blinds_Open1234", "h");
      delay(500);
      digitalWrite(D7,LOW);
  }
  if (D1 == HIGH){
     Particle.publish("Open_Blinds","t", PUBLIC);
     delay(5000);
  } else if (D2 == HIGH){
     Particle.publish("close_blinds","l", PUBLIC);
     delay(5000);
  }
  delay(1000);
}

Patrick's Code

C/C++
int Tilt_Close = D1;
int Tilt_Open = D2;

//Configure the pins as inputs
void setup() {

    pinMode(D1, INPUT);
    pinMode(D2, INPUT);
    Particle.subscribe("tilt_close", tilt_blind_close, "43002e000347363339343638");
    Particle.subscribe("Tilt_Blinds", tilt_blinds_open, "43002e000347363339343638");
}

//Now publish the data to the cloud so that the other photons can subscribe to it
//System.sleep causes the loop to only publish to the cloud one time
void tilt_blind_close(const char *event, const char *data){
    digitalRead(D1)==HIGH;
        Particle.publish("Blinds_Tilt_Open", "to", PUBLIC);
        delay(2000); //This number can be whatever works best for the system
        System.sleep(40); //Again, depends on what works best
}
void tilt_blinds_open(const char *event, const char *data){
 digitalRead(D2)==HIGH;
    Particle.publish("Blinds_Tilt_Close", "tc", PUBLIC);
    delay(2000); //This number can be whatever works best for the system
    System.sleep(40); //Again, depends on what works best
}

//Now for Jacob's part

// Give variables to Jacob's pin inputs
int Open_Blinds = D1;
int Close_Blinds = D2;

//Configure the pins as inputs
;void Setup(){

    pinMode(D1, INPUT);
    pinMode(D2, INPUT);
    Particle.subscribe("Open_Blinds", Open, "42004c001051363036373538");
    Particle.subscribe("close_blinds", Close, "42004c001051363036373538");
}

//Now publish the data to the cloud so that the other photons can subscribe to it
//System.sleep causes the loop to only publish to the cloud one time
void Open(const char *event, const char *data){
    digitalRead(D1)==HIGH;
        Particle.publish("Open", "o", PUBLIC);
        delay(2000); //This number can be whatever works best for the system
        System.sleep(40); //Again, depends on what works best
}
void Close(const char *event, const char *data){
    digitalRead(D2)==HIGH;
    Particle.publish("Close","c", PUBLIC);
    delay(2000); //This number can be whatever works best for the system
    System.sleep(40); //Again, depends on what works best
}

Credits

Daniel Midgette

Daniel Midgette

1 project • 0 followers
Jacob Burwell

Jacob Burwell

1 project • 0 followers
Patrick Kennedy

Patrick Kennedy

1 project • 0 followers

Comments

Add projectSign up / Login