/* HARDSOFT 3/2017 Ovladaci panel pro anteny SALA Arduino Nano. Piny D2-D9 jsou pro tlacitka. 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 */ #include "Wire.h" byte a=1; byte b=102; byte c=0; void setup() { Serial.begin (9600); // nastaveni pinu for (int i=2; i<10; i++){ pinMode(i,INPUT); digitalWrite(i, HIGH); } Wire.begin(); Wire.beginTransmission(0x20); //begins talking to the slave device Wire.write(0x00); //selects the IODIRA register Wire.write(0x00); //this sets all port A pins to outputs Wire.endTransmission(); //stops talking to device Wire.beginTransmission(0x20);//begins talking again to slave device Wire.write(0x01); //selects the IODIRB register Wire.write(0x00); // sets all port B pins to outputs Wire.endTransmission(); //ends communication with slave device test(); } void loop() { //----------------------------------------------- PORTa LED tlacitka,PORTb rele if (digitalRead(2) == LOW){a = B00000001; b = B01100110;} //NORTH else if (digitalRead(3) == LOW){a = B00000010; b = B01100000;} //NORTHEAST else if (digitalRead(4) == LOW){a = B00000100; b = B01101001;} //EAST else if (digitalRead(5) == LOW){a = B00001000; b = B00001001;} //SOUTHEAST else if (digitalRead(6) == LOW){a = B00010000; b = B10011001;} //SOUTH else if (digitalRead(7) == LOW){a = B00100000; b = B10010000;} //SOUTHWEST else if (digitalRead(8) == LOW){a = B01000000; b = B10010110;} //WEST else if (digitalRead(9) == LOW){a = B10000000; b = B00000110;} //NORTHWEST Wire.beginTransmission(0x20); Wire.write(0x12); // address port A Wire.write((byte)a); //value to send Wire.endTransmission(); Wire.beginTransmission(0x20); Wire.write(0x13); // address port B Wire.write((byte)b); // value to send Wire.endTransmission(); } void test() { for (int i=0; i<8; i++){ c = (1<