1 | #include <avr/io.h> |
2 | #include <util/delay.h> |
3 | |
4 | /*#define PB0 0
|
5 | #define PB1 1
|
6 | #define PB2 2
|
7 | #define PB3 3*/
|
8 | |
9 | |
10 | /*Prototypes*/
|
11 | void step1(void); |
12 | void step2(void); |
13 | void step3(void); |
14 | void step4(void); |
15 | |
16 | |
17 | int main(void) |
18 | {
|
19 | |
20 | DDRB |= (1<<PB0) | (1<<PB1) | (1<<PB2) | (1<<PB3); |
21 | |
22 | while(1) |
23 | {
|
24 | step1(); |
25 | _delay_ms(50); |
26 | step2(); |
27 | _delay_ms(50); |
28 | step3(); |
29 | _delay_ms(50); |
30 | step4(); |
31 | _delay_ms(50); |
32 | }
|
33 | return 0; |
34 | }
|
35 | |
36 | |
37 | void step1() |
38 | {
|
39 | /*1100*/
|
40 | PORTB |= (1<<PB0); |
41 | PORTB |= (1<<PB1); |
42 | PORTB &=~ (1<<PB2); |
43 | PORTB &=~ (1<<PB3); |
44 | }
|
45 | |
46 | |
47 | void step2() |
48 | {
|
49 | /*0110*/
|
50 | PORTB &=~ (1<<PB0); |
51 | PORTB |= (1<<PB1); |
52 | PORTB |= (1<<PB2); |
53 | PORTB &=~ (1<<PB3); |
54 | }
|
55 | |
56 | void step3() |
57 | {
|
58 | /*0011*/
|
59 | PORTB &=~ (1<<PB0); |
60 | PORTB &=~ (1<<PB1); |
61 | PORTB |= (1<<PB2); |
62 | PORTB |= (1<<PB3); |
63 | }
|
64 | |
65 | void step4() |
66 | {
|
67 | /*1001*/
|
68 | PORTB |= (1<<PB0); |
69 | PORTB &=~ (1<<PB1); |
70 | PORTB &=~ (1<<PB2); |
71 | PORTB |= (1<<PB3); |
72 | }
|