Advertisement
dzieciol

fdsfds

Dec 1st, 2017
545
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. #include<avr/io.h>
  2. #include<avr/interrupt.h>
  3. //#include<avr/delay.h>
  4. #define F_CPU 1000000U;
  5.  
  6. volatile char x;
  7. volatile char i;
  8.  
  9. ISR(INT0_vect){
  10. PORTC=x;
  11. /*
  12. if(i==4){
  13. if(x == 0b00001110)PORTB = 0x00; //0
  14. if(x == 0b00001101)PORTB = 0x20; //4
  15. if(x == 0b00001011)PORTB = 0x10; //8
  16. if(x == 0b00000111)PORTB = 0x30; //12
  17. }
  18. if(i==5){
  19. if(x == 0b00001110)PORTB = 0x80; //1
  20. if(x == 0b00001101)PORTB = 0xA0; //5
  21. if(x == 0b00001011)PORTB = 0x90; //9
  22. if(x == 0b00000111)PORTB = 0xB0; //13
  23. }
  24. if(i==6){
  25. if(x == 0b00001110)PORTB = 0x40; //2
  26. if(x == 0b00001101)PORTB = 0x60; //6
  27. if(x == 0b00001011)PORTB = 0x50; //10
  28. if(x == 0b00000111)PORTB = 0x70; //14
  29. }
  30. if(i==7){
  31. if(x == 0b00001110)PORTB = 0xC0; //3
  32. if(x == 0b00001101)PORTB = 0xE0; //7
  33. if(x == 0b00001011)PORTB = 0xD0; //11
  34. if(x == 0b00000111)PORTB = 0xf0; //15
  35. }
  36. */
  37.  
  38.  
  39. }
  40.  
  41.  
  42. int main(void){
  43. DDRA = 0xF0;
  44. DDRC = 0xFF;
  45.  
  46. GICR|= (1<<INT0);
  47. //MCUCR |= (1<<ISC00) | (1<<ISC01);
  48. sei();
  49.  
  50. char x;
  51. PORTC=0;
  52. while(1){
  53. for (i= 4 ; i<8 ; i++){
  54. PORTA = ~(_BV(i));
  55. //_delay_ms(1);
  56. x = PINA;
  57.  
  58. /*
  59. if(i==4){
  60. if(x == 0b00001110)PORTB = 0x00; //0
  61. if(x == 0b00001101)PORTB = 0x20; //4
  62. if(x == 0b00001011)PORTB = 0x10; //8
  63. if(x == 0b00000111)PORTB = 0x30; //12
  64. }
  65. if(i==5){
  66. if(x == 0b00001110)PORTB = 0x80; //1
  67. if(x == 0b00001101)PORTB = 0xA0; //5
  68. if(x == 0b00001011)PORTB = 0x90; //9
  69. if(x == 0b00000111)PORTB = 0xB0; //13
  70. }
  71. if(i==6){
  72. if(x == 0b00001110)PORTB = 0x40; //2
  73. if(x == 0b00001101)PORTB = 0x60; //6
  74. if(x == 0b00001011)PORTB = 0x50; //10
  75. if(x == 0b00000111)PORTB = 0x70; //14
  76. }
  77. if(i==7){
  78. if(x == 0b00001110)PORTB = 0xC0; //3
  79. if(x == 0b00001101)PORTB = 0xE0; //7
  80. if(x == 0b00001011)PORTB = 0xD0; //11
  81. if(x == 0b00000111)PORTB = 0xf0; //15
  82. }
  83. */
  84. }
  85.  
  86. }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement