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 LED_1 0x06; // 0000 0110
- #define LED_2 0x5b; // 0101 1011
- #define LED_3 0x4f; // 0100 1111
- #define LED_4 0x66; // 0110 0110
- #define LED_5 0x6d; // 0110 1101
- #define LED_6 0x7d; // 0111 1101
- int main(void){
- unsigned char i,n,l;
- DDRD = 0xFF;
- PORTD = 0xFF;
- DDRC = 0x00;
- PORTC = 0X01;
- DDRB = 0x10;
- PORTB = 0x00;
- while(1) {
- while(PINC & 0x01) ++l;
- _delay_ms(140);
- while(!(PINC & 0x01)) l+=2;
- _delay_ms(140);
- n = l % 6 + 1;
- for(i=1; i <= n; i++){
- switch(i){
- PORTD = ~LED_1
- break;
- case 2:
- PORTD = ~LED_2;
- break;
- case 3:
- PORTD = ~LED_3;
- break;
- case 4:
- PORTD = ~LED_4;
- break;
- case 5:
- PORTD = ~LED_5;
- break;
- case 6:
- PORTD = ~LED_6;
- }
- PORTB |= 0X10;
- _delay_ms(50);
- PORTB &= ~0X10;
- _delay_ms(450);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement