Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<avr/io.h>
- #include<avr/delay.h>
- int main(void){
- DDRA = 0xF0;
- DDRB = 0xFF;
- char x;
- while(1){
- PORTA = 0xFF;
- for (int i= 4 ; i<8 ; i++){
- PORTA = ~(_BV(i));
- _delay_ms(1);
- x = PINA & 0x0F;
- if(i==4){
- if(x == 0b00001110)PORTB = 0x00; //0
- if(x == 0b00001101)PORTB = 0x20; //4
- if(x == 0b00001011)PORTB = 0x10; //8
- if(x == 0b00000111)PORTB = 0x30; //12
- }
- if(i==5){
- if(x == 0b00001110)PORTB = 0x80; //1
- if(x == 0b00001101)PORTB = 0xA0; //5
- if(x == 0b00001011)PORTB = 0x90; //9
- if(x == 0b00000111)PORTB = 0xB0; //13
- }
- if(i==6){
- if(x == 0b00001110)PORTB = 0x40; //2
- if(x == 0b00001101)PORTB = 0x60; //6
- if(x == 0b00001011)PORTB = 0x50; //10
- if(x == 0b00000111)PORTB = 0x70; //14
- }
- if(i==7){
- if(x == 0b00001110)PORTB = 0xC0; //3
- if(x == 0b00001101)PORTB = 0xE0; //7
- if(x == 0b00001011)PORTB = 0xD0; //11
- if(x == 0b00000111)PORTB = 0xf0; //15
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement