Skip to content

Instantly share code, notes, and snippets.

@Neui
Created November 8, 2015 13:37
Show Gist options
  • Select an option

  • Save Neui/31620ff1b8cb8e0929a6 to your computer and use it in GitHub Desktop.

Select an option

Save Neui/31620ff1b8cb8e0929a6 to your computer and use it in GitHub Desktop.
A counter for use with http://lights.climagic.com/ - Run with ./a.out > /dev/udp/lights.climagic.com/45444
#include <stdio.h> /* For printf, fflush and setbuf */
#include <unistd.h> /* For sleep'ing */
int main() {
int prev = 0, curr, changed, temp;
setbuf(stdout, NULL); // Unbuffered
for (curr = 0; curr <= 511; curr++) {
changed = curr ^ prev;
prev = curr;
for (temp = 0; temp <= 8; temp++)
if ((changed & (1 << temp)) >> temp != 0)
printf("%c", '9' - temp );
fflush(stdout);
if (changed != 0)
printf("\n");
sleep(1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment