Michael Schoonmaker
Published © GPL3+

Internet-Connected Popcorn Popper

A hot air popcorn popper triggered via the Internet! (Built for the Bellingham Codes May event.)

BeginnerFull instructions provided1 hour1,218
Internet-Connected Popcorn Popper

Things used in this project

Hardware components

Photon
Particle Photon
×1
Particle Relay Shield v2
×1
Poplite Hot Air Popper
×1
12V, 2A Power Supply
×1

Software apps and online services

Losant Platform
Losant Platform
Particle Cloud API

Story

Read more

Code

PopcornRelay.ino

Arduino
The onboard Particle firmware. No libraries used or required.
const int MOTOR_PIN = D3;
const unsigned long MOTOR_DURATION = 500;
const unsigned long POPCORN_DURATION = (2 * 60 + 20) * 1000; // 2 minutes, 20 seconds
const int RELAY_PIN = D0;

bool making_popcorn = false;
unsigned long started_making_popcorn;
bool running_motor = false;
unsigned long started_running_motor;

int make_popcorn (String command);

void setup () {
    pinMode (MOTOR_PIN, OUTPUT);
    pinMode (RELAY_PIN, OUTPUT);

    Particle.function ("make_popcorn", make_popcorn);
    Particle.function ("start_motor", start_motor);
}

void loop () {
    if (making_popcorn) {
        unsigned long duration = millis () - started_making_popcorn;
        if (duration > POPCORN_DURATION) {
            digitalWrite (RELAY_PIN, LOW);
            making_popcorn = false;
        }
    }
    
    if (running_motor) {
        unsigned long duration = millis () - started_running_motor;
        if (duration > MOTOR_DURATION) {
            digitalWrite(MOTOR_PIN, LOW);
            running_motor = false;
            make_popcorn (String (""));
        }
    }
}

int make_popcorn (String command) {
    if (making_popcorn) {
        return 0;
    }
    
    making_popcorn = true;
    started_making_popcorn = millis();
    digitalWrite (RELAY_PIN, HIGH);

    return 1;
}

int start_motor (String command) {
    running_motor = true;
    started_running_motor = millis();
    digitalWrite(MOTOR_PIN, HIGH);
    
    return 1;
}

Credits

Michael Schoonmaker

Michael Schoonmaker

2 projects • 2 followers
Half of @LegacyofPlay. Advisor @TheUnpub. If I trick one more rock into thinking, I get a free lunch box! he/him

Comments