Vincent RobertsonCourtney Holland
Created April 13, 2017

Brew with Light

Ever wish a cup of coffee was there for you as soon as you woke up? Wait no more, we have solved your problem with our Brew with Light.

Beginner6 hours13
Brew with Light

Things used in this project

Hardware components

Jumper wires (generic)
Jumper wires (generic)
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×2
Photo resistor
Photo resistor
×1
Resistor 221 ohm
Resistor 221 ohm
×1
Keurig Coffee maker
×1
Servos (Tower Pro MG996R)
×1
Photon
Particle Photon
×2

Software apps and online services

Particle

Story

Read more

Schematics

Photoresistor

Servo Motor

Code

Photoresistor

C/C++
int led = D0; 

int photoresistor = A0; 

int power = A5; 

int analogvalue; 


void setup() {

    
    pinMode(led,OUTPUT);
    pinMode(photoresistor,INPUT);  
    pinMode(power,OUTPUT); 
   
    digitalWrite(power,HIGH);

    
    Particle.variable("analogvalue", &analogvalue, INT);
    

}




void loop() {

    
    analogvalue = analogRead(photoresistor);
    
    if (analogvalue>=64){
        Particle.publish("800853132_lights_on", "coffee_time", 1001);
    delay(100);
}
}

Motor

C/C++
Servo myservo;  // create servo object to control a servo
                // a maximum of eight servo objects can be created
int led2 = D7;
int pos = 0;    // variable to store the servo position
int servo = D0;
void setup()
{
  myservo.attach(D0);  // attaches the servo on the D0 pin to the servo object
  // Only supported on pins that have PWM
  Particle.function("Coffee",servo1);
  pinMode(led2, OUTPUT);    
  Particle.subscribe("800853132_lights_on",loop, "270035001847343338333633");
}

void loop(const char *event, const char *data)
{
 
 
                                 
          myservo.write(pos = -1);              
          delay(2000);                       
        
              
          myservo.write(pos = 80);
          
          Particle.publish("800854853_Coffee_Is_Ready", "Brew_Started_Light/Alarm");
          delay(600000);
        
     Particle.publish("800854853_Coffee_Is_Ready", "Brew_Executed_Light/Alarm");
    
     
         
          
}     

int servo1(String command) {

    if (command=="on") {
        myservo.write(pos = -1);
        delay(2000);                       
        myservo.write(pos = 80);
        Particle.publish("800854853_Coffee_Is_Ready", "Brew_Started_Phone");
        return 1;
    }
    else if (command=="off") {
        myservo.write(pos = -1);              
        delay(2000);                       
        myservo.write(pos = 80);
        Particle.publish("800854853_Coffee_Is_Ready", "Coffee_Off_Phone");
        return 0;
    }
    else {
        return -1;
    }
    
    delay(600000);
        
     Particle.publish("800854853_Coffee_Is_Ready", "Brew_Executed_Phone");

}

Credits

Vincent Robertson

Vincent Robertson

1 project • 0 followers
Courtney Holland

Courtney Holland

1 project • 0 followers
Thanks to Let them Brew.

Comments