Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<avr/io.h>
- #include<avr/interrupt.h>
- //#include<avr/delay.h>
- #define F_CPU 1000000U;
- volatile char x;
- volatile char i;
- ISR(INT0_vect){
- PORTC=x;
- /*
- 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
- }
- */
- }
- int main(void){
- DDRA = 0xF0;
- DDRC = 0xFF;
- GICR|= (1<<INT0);
- //MCUCR |= (1<<ISC00) | (1<<ISC01);
- sei();
- char x;
- PORTC=0;
- while(1){
- for (i= 4 ; i<8 ; i++){
- PORTA = ~(_BV(i));
- //_delay_ms(1);
- x = PINA;
- /*
- 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