Corey Hobbs
Published © Apache-2.0

Pomodoro Timer

Particle Internet Button turned into Pomodoro Timer (any time interval!)

BeginnerShowcase (no instructions)1 hour2,546
Pomodoro Timer

Things used in this project

Story

Read more

Code

Pomodoro Timer App

Arduino
// This #include statement was automatically added by the Particle IDE.
#include "InternetButton/InternetButton.h"


InternetButton b = InternetButton();

unsigned long startTime = 0;
int ledNum = 0;
bool checkFlag = false;
bool subFlag = false;



void setup() {
    //initiating Internet button
    b.allLedsOff();
    b.begin();
    initPomo();
}

void loop() {
    checkButton();
    pomoMain();
}//main Application Loop

void pomoMain(){
    if(millis()-startTime > 750UL && checkFlag){//750UL = .75seconds, ex: 327000UL = 5.45 minutes (at 5.45 minutes this will make a work session around 45 minutes with a 15 minute break)
        if(ledNum > 10){
            checkFlag = false;
            subFlag = true;
            partiTime();
        }else if(ledNum > 7){
            b.ledOn(++ledNum, 0,53,0); //ex: b.ledOn(ledNumber, red, green, blue) feel free to Modify these colors
        }else{
            b.ledOn(++ledNum, 105, 0,255); // feel free to modify these colors :)
        }
        
        startTime = millis();
        
    }
}//pomoMain() is end of "work" cycle

void partiTime(){
    
    while(b.buttonOn(3) == 0 && subFlag){
        b.rainbow(10);
        Particle.process();
    }
    b.allLedsOff();
    b.playSong("E5,2,G5,8,E6,8,C6,4,D6,8,G6,8"); //song that plays at Reset
    initPomo();
    
}//partiTime function = end of full cycle

void initPomo(){
    ledNum = 0;
    b.ledOn(ledNum, 105,0,255);
    startTime = millis(); 
    checkFlag = false;
    subFlag = false;
}//initializing function for variables

void checkButton(){
    
    if(b.buttonOn(3) || b.buttonOn(2)){
        checkFlag = !checkFlag;
        delay(50);
        while(b.buttonOn(3));
        delay(50);
    }//end of checkFlag toggle
    
}//checkButton() is for Flag Checking

Credits

Corey Hobbs

Corey Hobbs

1 project • 2 followers
engineer at particle

Comments