Advertisement
Guest User

Untitled

a guest
Dec 15th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. unsigned char odczyt(){
  2.  
  3. DDRA = 0xF0;
  4. DDRB = 0xFF;
  5. char x;
  6.  
  7. while(1){
  8. PORTA = 0xFF;
  9. for (int i= 4 ; i<8 ; i++){
  10. PORTA = ~(_BV(i));
  11. _delay_ms(1);
  12. x = PINA & 0x0F;
  13.  
  14. if(i==4){
  15. if(x == 0b00001110)
  16. if(x == 0b00001101)
  17. if(x == 0b00001011)
  18. if(x == 0b00000111)
  19. }
  20. if(i==5){
  21. if(x == 0b00001110)PORTB = 0x80; //1
  22. if(x == 0b00001101)PORTB = 0xA0; //5
  23. if(x == 0b00001011)PORTB = 0x90; //9
  24. if(x == 0b00000111)PORTB = 0xB0; //13
  25. }
  26. if(i==6){
  27. if(x == 0b00001110)PORTB = 0x40; //2
  28. if(x == 0b00001101)PORTB = 0x60; //6
  29. if(x == 0b00001011)PORTB = 0x50; //10
  30. if(x == 0b00000111)PORTB = 0x70; //14
  31. }
  32. if(i==7){
  33. if(x == 0b00001110)PORTB = 0xC0; //3
  34. if(x == 0b00001101)PORTB = 0xE0; //7
  35. if(x == 0b00001011)PORTB = 0xD0; //11
  36. if(x == 0b00000111)PORTB = 0xf0; //15
  37. }
  38.  
  39. }
  40.  
  41. }
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement