Created
November 8, 2015 13:37
-
-
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
This file contains hidden or 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
| #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