SHOW:
|
|
- or go back to the newest paste.
1 | #include <avr/io.h> | |
2 | #include <util/delay.h> // for _delay_ms() | |
3 | ||
4 | int main(void) | |
5 | { | |
6 | DDRC = 0x0F; // initialize port C | |
7 | // motors connected across PC0...Pc3 | |
8 | while(1) | |
9 | { | |
10 | // clockwise rotation | |
11 | PORTC = 0b00000101; // PC0 = High = Vcc | |
12 | // PC1 = Low = 0 | |
13 | // PC2 = High = Vcc | |
14 | // PC3 = Low = 0 | |
15 | ||
16 | _delay_ms(500); // wait 0.5s | |
17 | ||
18 | // counter-clockwise rotation | |
19 | PORTC = 0b00001010; // PC0 = Low = 0 | |
20 | // PC1 = High = Vcc | |
21 | // PC2 = Low = 0 | |
22 | // PC3 = High = Vcc | |
23 | ||
24 | _delay_ms(500); // wait 0.5s | |
25 | } | |
26 | } |