Skip to content

Instantly share code, notes, and snippets.

@adamwolf
Created September 21, 2015 02:14
Show Gist options
  • Save adamwolf/11ca3a8bfba67c113073 to your computer and use it in GitHub Desktop.
Save adamwolf/11ca3a8bfba67c113073 to your computer and use it in GitHub Desktop.
Simple Beeminder Particle Internet Button Sketch
#include "InternetButton/InternetButton.h"
//Simple, simple Beeminder example program
//Connect to Beeminder through IFTTT
//to automatically add datapoints when you push a physical button!
// September 20th 2015
// Adam Wolf, @adamwwolf
// http://feelslikeburning.com
InternetButton b = InternetButton();
void setup() {
Spark.publish("beebutton_powered_on", NULL, 60, PRIVATE);
b.begin();
//do a little animation to show power on
b.allLedsOn(255, 255, 255);
delay(250);
b.allLedsOff();
b.allLedsOn(255, 0, 0);
delay(250);
b.allLedsOff();
b.allLedsOn(0, 255, 0);
delay(250);
b.allLedsOff();
b.allLedsOn(0, 0, 255);
delay(250);
b.allLedsOff();
}
void loop() {
if (b.buttonOn(1) || b.buttonOn(2) || b.buttonOn(3) || b.buttonOn(4)) //if any of the 4 buttons are pushed
{
b.allLedsOn(0, 255, 0); // turn on all the leds green
while (!b.allButtonsOff())
{
} //wait until all the buttons are released
Spark.publish("allbuttonsreleased", NULL, 60, PRIVATE); // publish an event, which IFTTT can pick up on
b.allLedsOn(255, 255, 255); //turn on all the lights white
delay(250); //wait a quarter of a second
b.allLedsOff(); //turn off all the leds
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment