Thomas Nguyen
Published

Lane Tech HS - PCL - IoT Cereal/Food Dispenser

A cereal (or whatever you'd like it to be) dispenser, that dispenses anything from the manual button, or from your phone.

BeginnerFull instructions provided3 hours625
Lane Tech HS - PCL - IoT Cereal/Food Dispenser

Things used in this project

Hardware components

Photon
Particle Photon
×1
Servos (Tower Pro MG996R)
×1
Micro Limit Switch
OpenBuilds Micro Limit Switch
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Blynk
Blynk

Story

Read more

Schematics

cereal_TMzUtlCZP7.fzz

Code

Food dispenser Code

Arduino
This code will allow you to use the limit switch as well as Blynk to dispense food. The code will allow the duration of the dispenser, dispensing food to be changed in Blynk, and to show the display on the app interface, how long the dispenser will dispense food.
#define BLYNK_PRINT Serial  // Set serial output for debug prints
//#define BLYNK_DEBUG       // Uncomment this to see detailed prints

#include <blynk.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "51890ac9811d44b4bf44bec797203a39";


Servo myservo;  // create servo object to control a servo
               

int secs = 0;
int BTN_THING = 2;
void setup()
{
    Serial.begin(9600);
    delay(5000); 
    Blynk.begin(auth);
    pinMode(BTN_THING, INPUT_PULLUP);
    myservo.attach(D1);
    myservo.write(0);
    
}


BLYNK_WRITE(V1) {
    //turns the servo & sends notification
    myservo.write(180);
    
    
    delay(secs);
    
    // turns it back 
    myservo.write(0);
    Blynk.notify("You have been served :D");
}


BLYNK_WRITE(V2) {
    //slider that sets "secs" 
    if(param.asInt() == 0)
    {
        secs = 1000;
    }else if (param.asInt() == 1) {
        secs = 2000;
    }else if (param.asInt() == 2) {
        secs = 3000;
    }else if (param.asInt() == 3) {
        secs = 4000;
    }else if (param.asInt() == 4) {
        secs = 5000;
    }
    
}
BLYNK_READ(V3) {
    //display
    Blynk.virtualWrite(V3, secs/1000);
}

void loop()
{
    Blynk.run();
    int btnState = digitalRead(BTN_THING);
    Serial.println(btnState);
    
        if ( btnState == LOW )
    {
    	myservo.write(180);
    	Blynk.notify("You have been served :D");
  	
     }
     else
    	myservo.write(0);
}

Credits

Thomas Nguyen

Thomas Nguyen

1 project • 0 followers

Comments

Add projectSign up / Login