Arduino change outputs alone (PRO MINI)

Good day and Merry Chrismas to everyone

I have an issue, when i upload the code with only one of the subrutines (like SONLAS(); or UNAHR():wink: the right row in the matrix work good but if i try to do 2 subtines

like

SONLAS();
DOSHR();

both rows changed alone. for example

if i ask to display

SONLAS(); (this turn in the first row)
DOSHR(); (this turn in the second row)

in circuit the led that should turn in the first row are turn on in the second, and the ones that should turn on in the second turn on in the first.

i try more combinations but this alwayas happens, A and B are twisted

Here is the main and the slave code (I2C communication)

MAIN code

// Date and time functions using just software, based on millis() & timer

#include <Arduino.h>
#include <Wire.h>         // this #include still required because the RTClib depends on it
#include "RTClib.h"

#if defined(ARDUINO_ARCH_SAMD)
// for Zero, output on USB Serial console, remove line below if using programming port to program the Zero!
   #define Serial SerialUSB
#endif

RTC_Millis rtc;

int hora;
int minuto;
long previousMillis = 0;

void setup () {
    Wire.begin();
    Serial.begin(9600);
    // following line sets the RTC to the date & time this sketch was compiled
    //rtc.begin(DateTime(F(__DATE__), F(__TIME__)));
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
     //rtc.adjust(DateTime(2015, 12, 23, 0, 0, 0));
     pinMode(14, INPUT);
     pinMode(15, INPUT);
     pinMode(16, INPUT);
     pinMode(17, INPUT);
     
     pinMode(2, OUTPUT);
     pinMode(3, OUTPUT);
     pinMode(4, OUTPUT);
     pinMode(5, OUTPUT);
     pinMode(6, OUTPUT);
     pinMode(7, OUTPUT);
     pinMode(8, OUTPUT);
     pinMode(9, OUTPUT);
     pinMode(10, OUTPUT);
     pinMode(11, OUTPUT);
     pinMode(12, OUTPUT);
     pinMode(13, OUTPUT);
}

void loop () {
  
  DateTime now = rtc.now();
    
  unsigned long currentMillis = millis();
 
  if(currentMillis - previousMillis > 1000) {
    // save the last time you blinked the LED 
    previousMillis = currentMillis;   
    Serial.print(now.hour(), DEC);
    Serial.print(':');
    Serial.print(now.minute(), DEC);
    Serial.print(':');
    Serial.print(now.second(), DEC);
    Serial.println();
  }
  
  
  
  //SONLAS();
  //UNAHR();
  //DOSHR();  
  //TRESHR();
  //CUATROHR();
  //CINCOHR();
  //SEISHR();
  //SIETEHR();
  //DIEZHR();
  
    int btnhrinc = digitalRead(A0);
    if(btnhrinc == 1){
      hora = now.hour();
      minuto = now.minute();
      hora = hora + 1;
      rtc.adjust(DateTime(2015, 12, 23, hora, minuto, 0));
    }
    
    int btnhrdec = digitalRead(A1);
    if(btnhrdec == 1){
      hora = now.hour();
      minuto = now.minute();
      hora = hora - 1;
      if(hora == -1){
        hora = 23;
      }
      rtc.adjust(DateTime(2015, 12, 23, hora, minuto, 0));
    }
    
    int btnmininc = digitalRead(A2);
    if(btnmininc == 1){
      hora = now.hour();
      minuto = now.minute();
      minuto = minuto + 1;
      if(minuto == 60){
        minuto = 0;
      }
      rtc.adjust(DateTime(2015, 12, 23, hora, minuto, 0));
    }
    
    int btnmindec = digitalRead(A3);
    if(btnmindec == 1){
      hora = now.hour();
      minuto = now.minute();
      minuto = minuto - 1;
      if(minuto == -1){
        minuto = 59;
      }
      rtc.adjust(DateTime(2015, 12, 23, hora, minuto, 0));
    }
    
}

void SONLAS()
{
  digitalWrite(2, HIGH);
  Wire.beginTransmission(2);
  Wire.write(0);
  Wire.write(2);
  Wire.write(3);
  Wire.write(4);
  Wire.write(6);
  Wire.write(7);
  Wire.write(8);
  Wire.endTransmission();
  digitalWrite(2, LOW);
}

void UNAHR()
{
  digitalWrite(2, HIGH);
  Wire.beginTransmission(2);
  Wire.write(0);
  Wire.write(1);
  Wire.write(2);
  Wire.write(6);
  Wire.write(7);
  Wire.write(10);
  Wire.write(11);
  Wire.write(12);
  Wire.endTransmission();
  digitalWrite(2, LOW);
}

void DOSHR()
{
  digitalWrite(3, HIGH);
  Wire.beginTransmission(2);
  Wire.write(0);
  Wire.write(1);
  Wire.write(2);
  Wire.write(3);
  Wire.endTransmission();
  digitalWrite(3, LOW);
}

void TRESHR()
{ 
  digitalWrite(3, HIGH);
  Wire.beginTransmission(2);
  Wire.write(0);
  Wire.write(5);
  Wire.write(6);
  Wire.write(7);
  Wire.write(8);
  Wire.endTransmission();
  digitalWrite(3, LOW);
}

void CUATROHR()
{
  digitalWrite(4, HIGH);
  Wire.beginTransmission(2);
  Wire.write(0);
  Wire.write(1);
  Wire.write(2);
  Wire.write(3);
  Wire.write(4);
  Wire.write(5);
  Wire.write(6);
  Wire.endTransmission();
  digitalWrite(4, LOW);
}
void CINCOHR()
{
  digitalWrite(6, HIGH);
  Wire.beginTransmission(2);
  Wire.write(0);
  Wire.write(1);
  Wire.write(2);
  Wire.write(3);
  Wire.write(4);
  Wire.write(5);
  Wire.endTransmission();
  digitalWrite(6, LOW);
}
void SEISHR()
{
  digitalWrite(3, HIGH);
  Wire.beginTransmission(2);
  Wire.write(0);
  Wire.write(8);
  Wire.write(9);
  Wire.write(10);
  Wire.write(11);
  Wire.endTransmission();
  digitalWrite(3, LOW);
}
void SIETEHR()
{
  digitalWrite(5, HIGH);
  Wire.beginTransmission(2);
  Wire.write(0);
  Wire.write(1);
  Wire.write(2);
  Wire.write(3);
  Wire.write(4);
  Wire.write(5);
  Wire.endTransmission();
  digitalWrite(5, LOW);
}
void OCHOHR()
{
  digitalWrite(6, HIGH);
  Wire.beginTransmission(2);
  Wire.write(0);
  Wire.write(5);
  Wire.write(6);
  Wire.write(7);
  Wire.write(8);
  Wire.endTransmission();
  digitalWrite(6, LOW);
}
void NUEVEHR()
{
  digitalWrite(5, HIGH);
  Wire.beginTransmission(2);
  Wire.write(0);
  Wire.write(8);
  Wire.write(9);
  Wire.write(10);
  Wire.write(11);
  Wire.write(12);
  Wire.endTransmission();
  digitalWrite(5, LOW);
}
void DIEZHR()
{
  digitalWrite(4, HIGH);
  Wire.beginTransmission(2);
  Wire.write(0);
  Wire.write(9);
  Wire.write(10);
  Wire.write(11);
  Wire.write(12);
  Wire.endTransmission();
  digitalWrite(4, LOW);
}
void ONCEHR()
{
  digitalWrite(6, HIGH);
  Wire.beginTransmission(2);
  Wire.write(0);
  Wire.write(8);
  Wire.write(9);
  Wire.write(10);
  Wire.write(11);
  Wire.endTransmission();
  digitalWrite(6, LOW);
}
void DOCEHR()
{
  digitalWrite(7, HIGH);
  Wire.beginTransmission(2);
  Wire.write(0);
  Wire.write(1);
  Wire.write(2);
  Wire.write(3);
  Wire.write(4);
  Wire.endTransmission();
  digitalWrite(7, LOW);
}

void LIMPIEZA()
{
  digitalWrite(2, LOW);
  digitalWrite(3, LOW);
  digitalWrite(4, LOW);
  digitalWrite(5, LOW);
  digitalWrite(6, LOW);
  digitalWrite(7, LOW);
  digitalWrite(8, LOW);
  digitalWrite(9, LOW);
  digitalWrite(10, LOW);
  digitalWrite(11, LOW);
  digitalWrite(12, LOW);
  digitalWrite(13, LOW);
  Wire.beginTransmission(2);
  Wire.write(0);
  Wire.endTransmission();
  
}

slave code

//comunicacion pin 27(SDA) y pin 28 (SCL) UNO
//comunicacion pin 27(SDA) y pin 28 (SCL) MINI PRO



#include <Wire.h>
#include <EEPROM.h>

int x;
int w;
int Col1 = 2;
int Col2 = 3;
int Col3 = 4;
int Col4 = 5;
int Col5 = 6;
int Col6 = 7;
int Col7 = 8;
int Col8 = 9;
int Col9 = 10;
int Col10 = 11;
int Col11 = 12;
int Col12 = 13;
int Min1 = 14;
int Min2 = 15;
int Min3 = 16;
int Min4 = 17;

void setup()
{
  Wire.begin(2);                // join i2c bus with address #2
  Wire.onReceive(RecibeEvento); // register event

  pinMode(Col1, OUTPUT);
  digitalWrite(Col1, HIGH);
  pinMode(Col2, OUTPUT);
  digitalWrite(Col2, HIGH);
  pinMode(Col3, OUTPUT);
  digitalWrite(Col3, HIGH);
  pinMode(Col4, OUTPUT);
  digitalWrite(Col4, HIGH);
  pinMode(Col5, OUTPUT);
  digitalWrite(Col5, HIGH);
  pinMode(Col6, OUTPUT);
  digitalWrite(Col6, HIGH);
  pinMode(Col7, OUTPUT);
  digitalWrite(Col7, HIGH);
  pinMode(Col8, OUTPUT);
  digitalWrite(Col8, HIGH);
  pinMode(Col9, OUTPUT);
  digitalWrite(Col9, HIGH);
  pinMode(Col10, OUTPUT);
  digitalWrite(Col10, HIGH);
  pinMode(Col11, OUTPUT);
  digitalWrite(Col11, HIGH);
  pinMode(Col12, OUTPUT);
  digitalWrite(Col12, HIGH);
  pinMode(Min1, OUTPUT);
  digitalWrite(Min1, HIGH);
  pinMode(Min2, OUTPUT);
  digitalWrite(Min2, HIGH);
  pinMode(Min3, OUTPUT);
  digitalWrite(Min3, HIGH);
  pinMode(Min4, OUTPUT);
  digitalWrite(Min4, HIGH);
}

void loop()
{
  x = Wire.read();    // receive byte as an integer
  
  if(x == 1){
    digitalWrite(Col1, LOW);
  }
  if(x == 2){
    digitalWrite(Col2, LOW);
  }
  if(x == 3){
    digitalWrite(Col3, LOW);
  }
  if(x == 4){
    digitalWrite(Col4, LOW);
  }
  if(x == 5){
    digitalWrite(Col5, LOW);
  }
  if(x == 6){
    digitalWrite(Col6, LOW);
  }
  if(x == 7){
    digitalWrite(Col7, LOW);
  }
  if(x == 8){
    digitalWrite(Col8, LOW);
  }
  if(x == 9){
    digitalWrite(Col9, LOW);
  }
  if(x == 10){
    digitalWrite(Col10, LOW);
  }
  if(x == 11){
    digitalWrite(Col11, LOW);
  }
  if(x == 12){
    digitalWrite(Col12, LOW);
  }
  if(x == 13){
    digitalWrite(Min1, LOW);
  }
  if(x == 14){
    digitalWrite(Min2, LOW);
  }
  if(x == 15){
    digitalWrite(Min3, LOW);
  }
  if(x == 16){
    digitalWrite(Min4, LOW);
  }
  
  if(x == 0){
    digitalWrite(Min1, HIGH);
    digitalWrite(Min2, HIGH);
    digitalWrite(Min3, HIGH);
    digitalWrite(Min4, HIGH);
    digitalWrite(Col1, HIGH);
    digitalWrite(Col2, HIGH);
    digitalWrite(Col3, HIGH);
    digitalWrite(Col4, HIGH);
    digitalWrite(Col5, HIGH);
    digitalWrite(Col6, HIGH);
    digitalWrite(Col7, HIGH);
    digitalWrite(Col8, HIGH);
    digitalWrite(Col9, HIGH);
    digitalWrite(Col10, HIGH);
    digitalWrite(Col11, HIGH);
    digitalWrite(Col12, HIGH);
  }
}

// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void RecibeEvento(int recibido)
{

}