Created
December 5, 2015 03:45
-
-
Save sunnycyk/450529030c044cf9d770 to your computer and use it in GitHub Desktop.
Duo Exampple
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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