Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <avr/io.h>
- #include <util/delay.h>
- #define W0 0x40;
- #define W1 0x79;
- #define W2 0x24;
- #define W3 0x30;
- #define W4 0x19;
- #define W5 0x12;
- #define W6 0x02;
- #define W7 0x78;
- #define W8 0x00;
- #define W9 0x10;
- #define E 0x06;
- int l;
- int main(void)
- {
- /* Wszystkie linie portu D będą wyjściami */
- DDRD = 0xff;
- /* linie PC0,PC1 będą wejściami z podciągnięciem do VCC */
- DDRC = 0x00;
- PORTC = 0xFF;
- PORTD = W0;
- l = 0;
- /* Początek nieskończonej pętli */
- while(1)
- {
- /* Jeśli pierwszy przycisk wciśnięty */
- if(!(PINC & 0x01))
- l+=1;
- if(!(PINC & 0x02))
- l-=1;
- if(l == 0) PORTD = W0;
- if(l == 1) PORTD = W1;
- if(l == 2) PORTD = W2;
- if(l == 3) PORTD = W3;
- if(l == 4) PORTD = W4;
- if(l == 5) PORTD = W5;
- if(l == 6) PORTD = W6;
- if(l == 7) PORTD = W7;
- if(l == 8) PORTD = W8;
- if(l == 9) PORTD = W9;
- if(l == 10) l = 0;
- if(l < 0) PORTD = E;
- if(l < -1) l = -1;
- _delay_ms(50);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement