diff options
| -rw-r--r-- | hello.c | 73 | ||||
| -rw-r--r-- | hello.hex | 43 |
2 files changed, 82 insertions, 34 deletions
@@ -1,35 +1,68 @@ +#include <avr/eeprom.h> #include <avr/io.h> #include <util/delay.h> -int -main (void) -{ +uint8_t state; + + +int main() { + state = eeprom_read_byte((uint8_t*)0) & 1; + if ((MCUSR & (1 << PORF)) != 0) { + MCUSR = 1; + state ^= 1; + eeprom_write_byte((uint8_t*)0, state); + } + DDRB |= _BV(DDB0); DDRB |= _BV(DDB1); DDRB |= _BV(DDB2); DDRB |= _BV(DDB3); DDRB |= _BV(DDB4); - while(1) { - PORTB ^= _BV(PB0); - _delay_ms(500); - PORTB ^= _BV(PB0); - PORTB ^= _BV(PB1); - _delay_ms(500); - PORTB ^= _BV(PB1); + while (1) { + if (state == 1) { + PORTB ^= _BV(PB4); + _delay_ms(500); + PORTB ^= _BV(PB4); + + PORTB ^= _BV(PB3); + _delay_ms(500); + PORTB ^= _BV(PB3); + + PORTB ^= _BV(PB2); + _delay_ms(500); + PORTB ^= _BV(PB2); + + PORTB ^= _BV(PB1); + _delay_ms(500); + PORTB ^= _BV(PB1); + + PORTB ^= _BV(PB0); + _delay_ms(500); + PORTB ^= _BV(PB0); + } + else { + PORTB ^= _BV(PB0); + _delay_ms(500); + PORTB ^= _BV(PB0); + + PORTB ^= _BV(PB1); + _delay_ms(500); + PORTB ^= _BV(PB1); - PORTB ^= _BV(PB2); - _delay_ms(500); - PORTB ^= _BV(PB2); + PORTB ^= _BV(PB2); + _delay_ms(500); + PORTB ^= _BV(PB2); - PORTB ^= _BV(PB3); - _delay_ms(500); - PORTB ^= _BV(PB3); + PORTB ^= _BV(PB3); + _delay_ms(500); + PORTB ^= _BV(PB3); - PORTB ^= _BV(PB4); - _delay_ms(500); - PORTB ^= _BV(PB4); - } + PORTB ^= _BV(PB4); + _delay_ms(500); + PORTB ^= _BV(PB4); + } + } } @@ -1,15 +1,30 @@ -:100000000EC015C014C013C012C011C010C00FC064
-:100010000EC00DC00CC00BC00AC009C008C011241E
-:100020001FBECFE5D2E0DEBFCDBF02D052C0E8CFC9
-:10003000B89AB99ABA9ABB9ABC9A51E042E034E0B5
-:1000400028E090E188B3852788BB69E979E981E0F8
-:10005000615070408040E1F7000088B3852788BB7D
-:1000600088B3842788BB69E979E981E061507040F1
-:100070008040E1F7000088B3842788BB88B38327DA
-:1000800088BB69E979E981E0615070408040E1F71F
-:10009000000088B3832788BB88B3822788BB69E9BF
-:1000A00079E981E0615070408040E1F7000088B359
-:1000B000822788BB88B3892788BB69E979E981E011
-:1000C000615070408040E1F7000088B3892788BB09
-:0600D000B9CFF894FFCF48
+:100000000EC01DC01CC01BC01AC019C018C017C02C
+:1000100016C015C014C013C012C011C010C01124E6
+:100020001FBECFE5D2E0DEBFCDBF10E0A0E6B0E05E
+:1000300001C01D92A136B107E1F702D0C6C0E0CFE2
+:1000400080E090E0ACD081708093600004B600FE48
+:100050000AC081E084BF60916000682760936000FF
+:1000600080E090E0A4D0B89AB99ABA9ABB9ABC9AA8
+:1000700061E042E034E028E090E18091600081306E
+:1000800009F046C058B3592758BB59E979E9E1E06E
+:1000900051507040E040E1F7000058B3592758BB79
+:1000A00058B3522758BB59E979E9E1E05150704003
+:1000B000E040E1F7000058B3522758BB58B353272C
+:1000C00058BB59E979E9E1E051507040E040E1F76F
+:1000D000000058B3532758BB58B3542758BB59E9AD
+:1000E00079E9E1E051507040E040E1F7000058B399
+:1000F000542758BB58B3582758BB59E979E9E1E070
+:1001000051507040E040E1F7000058B3852745C0EA
+:1001100088B3862788BB59E979E981E0515070405E
+:100120008040E1F7000088B3862788BB88B3842726
+:1001300088BBE9E959E971E0E15050407040E1F7CE
+:10014000000088B3842788BB88B3832788BB89E9EC
+:10015000E9E951E08150E0405040E1F7000088B308
+:10016000832788BB88B3822788BB79E989E9E1E0E6
+:1001700071508040E040E1F7000088B3822788BBDF
+:1001800088B3892788BB59E979E981E051507040EB
+:100190008040E1F7000088B3892788BB6ECFE199E2
+:1001A000FECF9FBB8EBBE09A99278DB30895262F73
+:1001B000E199FECF1CBA9FBB8EBB2DBB0FB6F89446
+:0E01C000E29AE19A0FBE01960895F894FFCFDF
:00000001FF
|
