
/* Ovladaci panel pro anteny SALA. 
Piny 22-29 jsou LED pro tlacitka.
Piny 30-37 kombinuji rele do pozadovanych smeru.

TABULKA PREPINANI:
NORTHWEST: Sepnout North_B & South_A
NORTHEAST: Sepnout East_B & West_A
SOUTHEAST: Sepnout South_B & North_A
SOUTHWEST: Sepnout West_B & East_A
NORTH: Sepnout North_B & East_B & South_A & West_A
EAST: Sepnout South_B & East_B & North_A & West_A
SOUTH: Sepnout South_B & West_B & North_A & East_A
WEST: Sepnout North_B & West_B & South_A & East_A

RELE:
North_A = D30; 
North_B = D31;
East_A = D32;
East_B = D33;
South_A = D34;
South_B = D35;
West_A = D36;
West_B = D37;

TLACITKA:
N = A15;  
E = A14;
S = A13;
W = A12;
NE = A11;
SE = A10;
SW = A9;
NW = A8; 

LED:
N = D22;  
E = D23;
S = D24;
W = D25;
NE = D26;
SE = D27;
SW = D28;
NW = D29; 

 */

 
 void setup()
{
  // nastaveni pinu
  
  DDRA = B11111111; // set PORTA (digital 7~0) to outputs
  DDRC = B11111111; // set PORTA (digital 7~0) to outputs
  DDRK = B00000000; // A8-15 input
  PORTK = B11111111; // A8-15 HIGH (pullup resistors)
  
  test();
  PORTA = B00000001; //Set NORTH as default
}
 
void loop()
{
  
  //----------------------------------------------- PORTA LED tlacitka,PORTC rele
                         if (digitalRead(A15) == LOW){PORTA = B00000001; PORTC = B01100110;}  //NORTH
                    else if (digitalRead(A14) == LOW){PORTA = B00000010; PORTC = B01100000;}  //NORTHEAST 
                    else if (digitalRead(A13) == LOW){PORTA = B00000100; PORTC = B01101001;}  //EAST
                    else if (digitalRead(A12) == LOW){PORTA = B00001000; PORTC = B00001001;}  //SOUTHEAST
                    else if (digitalRead(A11) == LOW){PORTA = B00010000; PORTC = B10011001;}  //SOUTH
                    else if (digitalRead(A10) == LOW){PORTA = B00100000; PORTC = B10010000;}  //SOUTHWEST
                    else if (digitalRead(A9) == LOW){PORTA = B01000000; PORTC = B10010110;}  //WEST
                    else if (digitalRead(A8) == LOW){PORTA = B10000000; PORTC = B00000110;}  //NORTHWEST
                    
}
void test()
{
  for (int i=0; i<8; i++){
   PORTA = (1<<i);
      delay(200);
   } 
   
}


