Created
March 21, 2010 11:06
-
-
Save ryukzak/339235 to your computer and use it in GitHub Desktop.
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
#define led_conduction 0xFF | |
#define dip_state 0 | |
#define init_led_state 1 | |
#define led_state 2 | |
#define rev_led_state 3 | |
char din, dip, state; | |
while (dip = read_dip()){ | |
switch (state){ | |
case dip_state: | |
din == led_conduction ? state = dip_init : din = dip; | |
break; | |
case init_led_state: | |
din = 0x01; | |
state = led_state; | |
break; | |
case led_state: | |
din == 0x80 ? state = rev_led_state : din << 1; | |
dip != led_conduction ? state = dip_state; | |
break; | |
case rev_led_state: | |
din == 0x01 ? state = led_state : din >> 1; | |
dip != led_conduction ? state = dip_state; | |
break; | |
} | |
set_din(din); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment