Skip to content

Instantly share code, notes, and snippets.

@sunnycyk
Created December 5, 2015 03:45
Show Gist options
  • Save sunnycyk/450529030c044cf9d770 to your computer and use it in GitHub Desktop.
Save sunnycyk/450529030c044cf9d770 to your computer and use it in GitHub Desktop.
Duo Exampple
// This #include statement was automatically added by the Particle IDE.
#include "TM1637Display/TM1637Display.h"
TM1637Display display(4, 5); // connect CLK to D4, DIO to D5
int followers = 0; // or start with number that in your profile
void setup()
{
Serial.begin(9600);
// subscribe Particle event
Particle.subscribe("newfollower", followerToggle);
display.setBrightness(0x0f);
display.showNumberDec(followers, true);
}
void loop()
{
// do nothing
}
// Will trigger when event happened
void followerToggle(const char *event, const char *data) {
Serial.println(data);
if (strcmp(data, "add") == 0) {
followers++;
}
display.setBrightness(0x0f);
display.showNumberDec(followers, true);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment