Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define F_CPU 1000000L
- #include <avr/io.h>
- #include <util/delay.h>
- #define LED0 (1<<0)
- #define LED1 (1<<PA1)
- #define LED2 (1<<PA2)
- #define LED3 (1<<PA3)
- #define LED4 (1<<PA4)
- #define LED5 (1<<PA5)
- #define LED6 (1<<PA6)
- #define LED7 (1<<PA7)
- int main(void){
- DDRA |= LED0 | LED1 | LED2 | LED3 | LED4 | LED5 | LED6 | LED7;
- uint8_t phase = 0;
- uint8_t dir = 0;
- while(1){
- switch(phase){
- case 0:{
- PORTA |= LED0 | LED1;
- PORTA &= ~(LED2 | LED3);
- if(dir==0) {phase += 1; _delay_ms(1000);}
- else {dir = 0;}
- break;
- }
- case 1:{
- PORTA |= LED2 | LED3;
- PORTA &= ~(LED0 | LED1);
- PORTA &= ~(LED4 | LED5);
- if(dir==0) {phase += 1; _delay_ms(1000);}
- else {phase -= 1; _delay_ms(1000);}
- break;
- }
- case 2:{
- PORTA |= LED4 | LED5;
- PORTA &= ~(LED6 | LED7);
- PORTA &= ~(LED2 | LED3);
- if(dir==0) {phase += 1; _delay_ms(1000);}
- else {phase -= 1; _delay_ms(1000);}
- break;
- }
- case 3:{
- PORTA |= LED6 | LED7;
- PORTA &= ~(LED4 | LED5);
- if(dir==0) {dir = 1;}
- else {phase -= 1; _delay_ms(1000);}
- break;
- }
- }
- //PORTA |= LED0 | LED1 | LED2 | LED3 | LED4 | LED5 | LED6 | LED7;
- //
- // _delay_ms(1000);
- //
- // PORTA &= ~(LED0 | LED1 | LED2 | LED3 | LED4 | LED5 | LED6 | LED7);
- //
- // _delay_ms(1000);
- //if(!(PINA&LED0)){
- // _delay_ms(50);
- // if((PINA&LED0)){
- // PORTA |= LED0;
- // _delay_ms(80);
- // PORTA &= ~LED0;
- // _delay_ms(80);
- // }
- //}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement