#include <LiquidCrystal.h>
#include <TimerOne.h>
LiquidCrystal _lcd1(12, 11, 10, 9, 8, 7);
int _dispTempLength1=0;
boolean _isNeedClearDisp1;
int adr_172301129_1;
float data1_172301129_1;
float data2_172301129_1;
float data3_172301129_1;
float data4_172301129_1;
bool data5_172301129_1;
bool data6_172301129_1;
bool data7_172301129_1;
bool data8_172301129_1;
bool ok_172301129_1;
bool in_old_172301129_1;
bool in_rf_172301129_1;
unsigned long impuls_172301129_1;
unsigned long time_old_172301129_1;
bool bit_172301129_1;
bool data_ok_172301129_1;
int adr_in_172301129_1;
int rand_in_172301129_1;
int data1_in_172301129_1;
int data2_in_172301129_1;
int data3_in_172301129_1;
int data4_in_172301129_1;
int data5_in_172301129_1;
int data6_in_172301129_1;
int data7_in_172301129_1;
int data8_in_172301129_1;
int CRC_in_172301129_1;
int CRC_172301129_1;
bool Svoy_signal_172301129_1;
byte Prinimaem_172301129_1;
int adr_4442697_1;
bool rf_send_4442697_1;
bool data1_4442697_1;
int data2_4442697_1;
int data3_4442697_1;
int data4_4442697_1;
bool data5_4442697_1;
bool data6_4442697_1;
bool data7_4442697_1;
bool data8_4442697_1;
bool rf_send_old_4442697_1;
int TX_4442697_1;
int rand_4442697_1;
int CRC_4442697_1;
int send_4442697_1[12];
byte M_4442697_1;
byte N_4442697_1;
unsigned long time_4442697_1;
int _disp6oldLength = 0;
int _disp4oldLength = 0;
bool _bounseInputD16S = 0;
bool _bounseInputD16O = 0;
unsigned long _bounseInputD16P = 0UL;
bool _bounseInputD17S = 0;
bool _bounseInputD17O = 0;
unsigned long _bounseInputD17P = 0UL;
int _disp8oldLength = 0;
int _disp13oldLength = 0;
bool _bounseInputD14S = 0;
bool _bounseInputD14O = 0;
unsigned long _bounseInputD14P = 0UL;
int _disp11oldLength = 0;
bool _trgr2 = 0;
int _disp10oldLength = 0;
bool _bounseInputD15S = 0;
bool _bounseInputD15O = 0;
unsigned long _bounseInputD15P = 0UL;
bool _bounseInputD18S = 0;
bool _bounseInputD18O = 0;
unsigned long _bounseInputD18P = 0UL;
int _disp5oldLength = 0;
int _disp12oldLength = 0;
int _disp3oldLength = 0;
int _disp7oldLength = 0;
int _disp14oldLength = 0;
bool _bounseInputD19S = 0;
bool _bounseInputD19O = 0;
unsigned long _bounseInputD19P = 0UL;
int _disp2oldLength = 0;
bool _bounseInputD4S = 0;
bool _bounseInputD4O = 0;
unsigned long _bounseInputD4P = 0UL;
int _disp9oldLength = 0;
bool _tim2I = 0;
bool _tim2O = 0;
unsigned long _tim2P = 0UL;
bool _trgr1 = 0;
bool _bounseInputD5S = 0;
bool _bounseInputD5O = 0;
unsigned long _bounseInputD5P = 0UL;
bool _gen1I = 0;
bool _gen1O = 0;
unsigned long _gen1P = 0UL;
bool _trgr4 = 0;
bool _trgr5 = 0;
int _disp1oldLength = 0;
void setup()
{
    pinMode(14, INPUT_PULLUP);
    pinMode(15, INPUT_PULLUP);
    pinMode(16, INPUT_PULLUP);
    pinMode(17, INPUT_PULLUP);
    pinMode(18, INPUT_PULLUP);
    pinMode(19, INPUT_PULLUP);
    pinMode(4, INPUT_PULLUP);
    pinMode(5, INPUT_PULLUP);
    _lcd1.begin(20, 2);
    _bounseInputD17O =  digitalRead(17);
    _bounseInputD18O =  digitalRead(18);
    _bounseInputD14O =  digitalRead(14);
    _bounseInputD16O =  digitalRead(16);
    _bounseInputD5O =  digitalRead(5);
    _bounseInputD4O =  digitalRead(4);
    _bounseInputD19O =  digitalRead(19);
    _bounseInputD15O =  digitalRead(15);
    Timer1.initialize(1000);
    Timer1.setPeriod(80);
    Timer1.start();
    Timer1.attachInterrupt(RF_172301129_1); // RF_172301129_1
    pinMode(2 , INPUT);
    pinMode(3, OUTPUT);
    digitalWrite(3, LOW);
}
void loop()
{
    if (_isNeedClearDisp1) 
    {
        _lcd1.clear();
        _isNeedClearDisp1= 0;
    }
    bool  _bounceInputTmpD19 =  (digitalRead (19));
    if (_bounseInputD19S)
    {
        if (millis() >= (_bounseInputD19P + 40))
        {
            _bounseInputD19O= _bounceInputTmpD19;
            _bounseInputD19S=0;
        }
    }
    else
    {
        if (_bounceInputTmpD19 != _bounseInputD19O)
        {
            _bounseInputD19S=1;
            _bounseInputD19P = millis();
        }
    }
    bool  _bounceInputTmpD15 =  (digitalRead (15));
    if (_bounseInputD15S)
    {
        if (millis() >= (_bounseInputD15P + 40))
        {
            _bounseInputD15O= _bounceInputTmpD15;
            _bounseInputD15S=0;
        }
    }
    else
    {
        if (_bounceInputTmpD15 != _bounseInputD15O)
        {
            _bounseInputD15S=1;
            _bounseInputD15P = millis();
        }
    }
    bool  _bounceInputTmpD17 =  (digitalRead (17));
    if (_bounseInputD17S)
    {
        if (millis() >= (_bounseInputD17P + 40))
        {
            _bounseInputD17O= _bounceInputTmpD17;
            _bounseInputD17S=0;
        }
    }
    else
    {
        if (_bounceInputTmpD17 != _bounseInputD17O)
        {
            _bounseInputD17S=1;
            _bounseInputD17P = millis();
        }
    }
    bool  _bounceInputTmpD5 =  (digitalRead (5));
    if (_bounseInputD5S)
    {
        if (millis() >= (_bounseInputD5P + 40))
        {
            _bounseInputD5O= _bounceInputTmpD5;
            _bounseInputD5S=0;
        }
    }
    else
    {
        if (_bounceInputTmpD5 != _bounseInputD5O)
        {
            _bounseInputD5S=1;
            _bounseInputD5P = millis();
        }
    }
    bool  _bounceInputTmpD18 =  (digitalRead (18));
    if (_bounseInputD18S)
    {
        if (millis() >= (_bounseInputD18P + 40))
        {
            _bounseInputD18O= _bounceInputTmpD18;
            _bounseInputD18S=0;
        }
    }
    else
    {
        if (_bounceInputTmpD18 != _bounseInputD18O)
        {
            _bounseInputD18S=1;
            _bounseInputD18P = millis();
        }
    }
    bool  _bounceInputTmpD16 =  (digitalRead (16));
    if (_bounseInputD16S)
    {
        if (millis() >= (_bounseInputD16P + 40))
        {
            _bounseInputD16O= _bounceInputTmpD16;
            _bounseInputD16S=0;
        }
    }
    else
    {
        if (_bounceInputTmpD16 != _bounseInputD16O)
        {
            _bounseInputD16S=1;
            _bounseInputD16P = millis();
        }
    }
    bool  _bounceInputTmpD14 =  (digitalRead (14));
    if (_bounseInputD14S)
    {
        if (millis() >= (_bounseInputD14P + 40))
        {
            _bounseInputD14O= _bounceInputTmpD14;
            _bounseInputD14S=0;
        }
    }
    else
    {
        if (_bounceInputTmpD14 != _bounseInputD14O)
        {
            _bounseInputD14S=1;
            _bounseInputD14P = millis();
        }
    }
    bool  _bounceInputTmpD4 =  (digitalRead (4));
    if (_bounseInputD4S)
    {
        if (millis() >= (_bounseInputD4P + 40))
        {
            _bounseInputD4O= _bounceInputTmpD4;
            _bounseInputD4S=0;
        }
    }
    else
    {
        if (_bounceInputTmpD4 != _bounseInputD4O)
        {
            _bounseInputD4S=1;
            _bounseInputD4P = millis();
        }
    }
    //Плата:1
// RF_8int_RX_v2
    ok_172301129_1 = false;
    if (data_ok_172301129_1) 
    {
        data_ok_172301129_1 = false;
        ok_172301129_1 = true;
    }
    if(ok_172301129_1) 
    {
        _tim2O = 1;
        _tim2I = 1;
    }
     else 
    {
         if(_tim2I) 
        {
            _tim2I = 0;
            _tim2P = millis();
        }
         else 
        {
             if (_tim2O) 
            {
                if (_isTimer(_tim2P, 20)) _tim2O = 0;
            }
        }
    }
    if (_tim2O) 
    {
        _dispTempLength1 = ((String("TX"))).length();
        if (_disp11oldLength > _dispTempLength1) 
        {
            _isNeedClearDisp1 = 1;
        }
        _disp11oldLength = _dispTempLength1;
        _lcd1.setCursor(17, 1);
        _lcd1.print((String("TX")));
    }
     else 
    {
        if (_disp11oldLength > 0) 
        {
            _isNeedClearDisp1 = 1;
            _disp11oldLength = 0;
        }
    }
    if(!(_bounseInputD15O)) _trgr4 = 0;
    if(!(_bounseInputD14O)) _trgr4 = 1;
    if (1) 
    {
         if (! _gen1I) 
        {
            _gen1I = 1;
            _gen1O = 1;
            _gen1P = millis();
        }
    }
     else 
    {
        _gen1I = 0 ;
        _gen1O= 0;
    }
    if (_gen1I) 
    {
          if (_isTimer (_gen1P , 300)) 
        {
             _gen1P = millis();
            _gen1O = ! _gen1O;
        }
    }
    if(!(_bounseInputD17O)) _trgr5 = 0;
    if(!(_bounseInputD16O)) _trgr5 = 1;
    if (!(((data6_172301129_1) || (_trgr5)))) 
    {
        _dispTempLength1 = ((String("OFF"))).length();
        if (_disp6oldLength > _dispTempLength1) 
        {
            _isNeedClearDisp1 = 1;
        }
        _disp6oldLength = _dispTempLength1;
        _lcd1.setCursor(4, 1);
        _lcd1.print((String("OFF")));
    }
     else 
    {
        if (_disp6oldLength > 0) 
        {
            _isNeedClearDisp1 = 1;
            _disp6oldLength = 0;
        }
    }
    if (((data6_172301129_1) || (_trgr5))) 
    {
        _dispTempLength1 = ((String("ON"))).length();
        if (_disp5oldLength > _dispTempLength1) 
        {
            _isNeedClearDisp1 = 1;
        }
        _disp5oldLength = _dispTempLength1;
        _lcd1.setCursor(4, 1);
        _lcd1.print((String("ON")));
    }
     else 
    {
        if (_disp5oldLength > 0) 
        {
            _isNeedClearDisp1 = 1;
            _disp5oldLength = 0;
        }
    }
    if(!(_bounseInputD19O)) _trgr1 = 0;
    if(!(_bounseInputD18O)) _trgr1 = 1;
    if (!(((data7_172301129_1) || (_trgr1)))) 
    {
        _dispTempLength1 = ((String("OFF"))).length();
        if (_disp8oldLength > _dispTempLength1) 
        {
            _isNeedClearDisp1 = 1;
        }
        _disp8oldLength = _dispTempLength1;
        _lcd1.setCursor(8, 1);
        _lcd1.print((String("OFF")));
    }
     else 
    {
        if (_disp8oldLength > 0) 
        {
            _isNeedClearDisp1 = 1;
            _disp8oldLength = 0;
        }
    }
    if (((data7_172301129_1) || (_trgr1))) 
    {
        _dispTempLength1 = ((String("ON"))).length();
        if (_disp7oldLength > _dispTempLength1) 
        {
            _isNeedClearDisp1 = 1;
        }
        _disp7oldLength = _dispTempLength1;
        _lcd1.setCursor(8, 1);
        _lcd1.print((String("ON")));
    }
     else 
    {
        if (_disp7oldLength > 0) 
        {
            _isNeedClearDisp1 = 1;
            _disp7oldLength = 0;
        }
    }
    if(!(_bounseInputD5O)) _trgr2 = 0;
    if(!(_bounseInputD4O)) _trgr2 = 1;
    if (!(((data8_172301129_1) || (_trgr2)))) 
    {
        _dispTempLength1 = ((String("OFF"))).length();
        if (_disp10oldLength > _dispTempLength1) 
        {
            _isNeedClearDisp1 = 1;
        }
        _disp10oldLength = _dispTempLength1;
        _lcd1.setCursor(12, 1);
        _lcd1.print((String("OFF")));
    }
     else 
    {
        if (_disp10oldLength > 0) 
        {
            _isNeedClearDisp1 = 1;
            _disp10oldLength = 0;
        }
    }
    if (((data8_172301129_1) || (_trgr2))) 
    {
        _dispTempLength1 = ((String("ON"))).length();
        if (_disp9oldLength > _dispTempLength1) 
        {
            _isNeedClearDisp1 = 1;
        }
        _disp9oldLength = _dispTempLength1;
        _lcd1.setCursor(12, 1);
        _lcd1.print((String("ON")));
    }
     else 
    {
        if (_disp9oldLength > 0) 
        {
            _isNeedClearDisp1 = 1;
            _disp9oldLength = 0;
        }
    }
    adr_4442697_1 = 123;
    rf_send_4442697_1 = _gen1O;
    data1_4442697_1 = 0;
    data2_4442697_1 = 0;
    data3_4442697_1 = 0;
    data4_4442697_1 = 0;
    data5_4442697_1 = _trgr4;
    data6_4442697_1 = _trgr5;
    data7_4442697_1 = _trgr1;
    data8_4442697_1 = _trgr2;
    // RF_8int_TX_v2
    if ((rf_send_4442697_1) && (!rf_send_old_4442697_1))  // если была команда "передать"
    {
        	rand_4442697_1 = random(65535); // случайное число
        	send_4442697_1[0] = adr_4442697_1; // заносим данные в массив
        	send_4442697_1[1] = data1_4442697_1 xor rand_4442697_1;
        	send_4442697_1[2] = data2_4442697_1 xor rand_4442697_1;
        	send_4442697_1[3] = data3_4442697_1 xor rand_4442697_1;
        	send_4442697_1[4] = data4_4442697_1 xor rand_4442697_1;
        	send_4442697_1[5] = rand_4442697_1;
        	send_4442697_1[6] = data5_4442697_1 xor rand_4442697_1;
        	send_4442697_1[7] = data6_4442697_1 xor rand_4442697_1;
        	send_4442697_1[8] = data7_4442697_1 xor rand_4442697_1;
        	send_4442697_1[9] = data8_4442697_1 xor rand_4442697_1;
        	CRC_4442697_1 = ((send_4442697_1[0] + send_4442697_1[1] + send_4442697_1[2] + send_4442697_1[3] + send_4442697_1[4] + send_4442697_1[5] + send_4442697_1[6] + send_4442697_1[7] + send_4442697_1[8] + send_4442697_1[9]) xor 44111) + 1; // вычисляем контрольную сумму
        	send_4442697_1[10] = CRC_4442697_1;
        	for (N_4442697_1=0; N_4442697_1<40; N_4442697_1++)   // передаем синхронизацию 40 импульсов
        	
        {
            	digitalWrite(3, HIGH);
            	time_4442697_1 = micros();
            while((micros() - time_4442697_1) < 1500); // задержка 1500мкс
            	digitalWrite(3, LOW);
            	time_4442697_1 = micros();
            while((micros() - time_4442697_1) < 1500); // задержка 1500мкс
            	
        }
        	for (N_4442697_1=0; N_4442697_1<11; N_4442697_1++)    // передаем данные (перебираем массив)
        	
        {
            		TX_4442697_1 = send_4442697_1[N_4442697_1];
            		for (M_4442697_1=0; M_4442697_1<16; M_4442697_1++)    // передаем данные (перебираем биты)
            		
            {
                		digitalWrite(3, HIGH);
                		if (bitRead(TX_4442697_1 , 15))
                		
                {
                    time_4442697_1 = micros();
                    while((micros() - time_4442697_1) < 1500);
                }
                 // задержка 1500мкс
                		else
                		
                {
                    time_4442697_1 = micros();
                    while((micros() - time_4442697_1) < 500);
                }
                 // задержка 500мкс
                		digitalWrite(3, LOW);
                		time_4442697_1 = micros();
                while((micros() - time_4442697_1) < 500); // задержка 500мкс
                		TX_4442697_1 = TX_4442697_1 << 1;
                		
            }
            	
        }
        	digitalWrite(3, HIGH); // передаем завершающий импульс
        	time_4442697_1 = micros();
        while((micros() - time_4442697_1) < 500); // задержка 500мкс
        	digitalWrite(3, LOW);
    }
    rf_send_old_4442697_1 = rf_send_4442697_1;
    if (!(((data5_172301129_1) || (_trgr4)))) 
    {
        _dispTempLength1 = ((String("OFF"))).length();
        if (_disp4oldLength > _dispTempLength1) 
        {
            _isNeedClearDisp1 = 1;
        }
        _disp4oldLength = _dispTempLength1;
        _lcd1.setCursor(0, 1);
        _lcd1.print((String("OFF")));
    }
     else 
    {
        if (_disp4oldLength > 0) 
        {
            _isNeedClearDisp1 = 1;
            _disp4oldLength = 0;
        }
    }
    if (((data5_172301129_1) || (_trgr4))) 
    {
        _dispTempLength1 = ((String("ON"))).length();
        if (_disp3oldLength > _dispTempLength1) 
        {
            _isNeedClearDisp1 = 1;
        }
        _disp3oldLength = _dispTempLength1;
        _lcd1.setCursor(0, 1);
        _lcd1.print((String("ON")));
    }
     else 
    {
        if (_disp3oldLength > 0) 
        {
            _isNeedClearDisp1 = 1;
            _disp3oldLength = 0;
        }
    }
    if (1) 
    {
        _dispTempLength1 = (((String((map((data4_172301129_1), (0), (1023), (100), (0))), DEC)))).length();
        if (_disp2oldLength > _dispTempLength1) 
        {
            _isNeedClearDisp1 = 1;
        }
        _disp2oldLength = _dispTempLength1;
        _lcd1.setCursor(12, 0);
        _lcd1.print(((String((map((data4_172301129_1), (0), (1023), (100), (0))), DEC))));
    }
     else 
    {
        if (_disp2oldLength > 0) 
        {
            _isNeedClearDisp1 = 1;
            _disp2oldLength = 0;
        }
    }
    if (1) 
    {
        _dispTempLength1 = (((String((map((data3_172301129_1), (0), (1023), (100), (0))), DEC)))).length();
        if (_disp1oldLength > _dispTempLength1) 
        {
            _isNeedClearDisp1 = 1;
        }
        _disp1oldLength = _dispTempLength1;
        _lcd1.setCursor(8, 0);
        _lcd1.print(((String((map((data3_172301129_1), (0), (1023), (100), (0))), DEC))));
    }
     else 
    {
        if (_disp1oldLength > 0) 
        {
            _isNeedClearDisp1 = 1;
            _disp1oldLength = 0;
        }
    }
    if (1) 
    {
        _dispTempLength1 = (((String((map((data2_172301129_1), (0), (1023), (100), (0))), DEC)))).length();
        if (_disp13oldLength > _dispTempLength1) 
        {
            _isNeedClearDisp1 = 1;
        }
        _disp13oldLength = _dispTempLength1;
        _lcd1.setCursor(4, 0);
        _lcd1.print(((String((map((data2_172301129_1), (0), (1023), (100), (0))), DEC))));
    }
     else 
    {
        if (_disp13oldLength > 0) 
        {
            _isNeedClearDisp1 = 1;
            _disp13oldLength = 0;
        }
    }
    if (1) 
    {
        _dispTempLength1 = (((String((map((data1_172301129_1), (0), (1023), (100), (0))), DEC)))).length();
        if (_disp12oldLength > _dispTempLength1) 
        {
            _isNeedClearDisp1 = 1;
        }
        _disp12oldLength = _dispTempLength1;
        _lcd1.setCursor(0, 0);
        _lcd1.print(((String((map((data1_172301129_1), (0), (1023), (100), (0))), DEC))));
    }
     else 
    {
        if (_disp12oldLength > 0) 
        {
            _isNeedClearDisp1 = 1;
            _disp12oldLength = 0;
        }
    }
    if (((analogRead (7))) <= (800)) 
    {
        _dispTempLength1 = ((String("BAT"))).length();
        if (_disp14oldLength > _dispTempLength1) 
        {
            _isNeedClearDisp1 = 1;
        }
        _disp14oldLength = _dispTempLength1;
        _lcd1.setCursor(17, 0);
        _lcd1.print((String("BAT")));
    }
     else 
    {
        if (_disp14oldLength > 0) 
        {
            _isNeedClearDisp1 = 1;
            _disp14oldLength = 0;
        }
    }
}
bool _isTimer(unsigned long startTime, unsigned long period)
{
    unsigned long currentTime;
    currentTime = millis();
    if (currentTime>= startTime) 
    {
        return (currentTime>=(startTime + period));
    }
     else 
    {
        return (currentTime >=(4294967295-startTime+period));
    }
}
void RF_172301129_1()
{
    // Обработчик RF_172301129_1 сигнала
    in_rf_172301129_1 = digitalRead(2);
    if ((in_rf_172301129_1) && (!in_old_172301129_1))	 // если было изменение на входе 0->1
    {
        	in_old_172301129_1 = in_rf_172301129_1;
        	impuls_172301129_1 = micros()- time_old_172301129_1;
        				 // вычисляем длину импульса и паузы
        	time_old_172301129_1 = micros();
        						 // обновляем время изменения сигнала на входе
        	if (impuls_172301129_1 > 3500) 
        {
            goto Clear_123456;
        }
        	 // помеха
        	if (impuls_172301129_1 < 750) 
        {
            return;
        }
        					 // помеха, уходим
        	if ((impuls_172301129_1 < 1500) && (Svoy_signal_172301129_1)) 
        {
            bit_172301129_1 = false;
            goto Save_123456;
        }
         // приняли ноль
        	if ((impuls_172301129_1 < 2500) && (Svoy_signal_172301129_1)) 
        {
            bit_172301129_1 = true;
            goto Save_123456;
        }
         // приняли единицу
        	if (impuls_172301129_1 > 2500) 
        {
            Svoy_signal_172301129_1 = true;
            Prinimaem_172301129_1 = 0;
            adr_in_172301129_1 = 0;
            CRC_in_172301129_1 = 0;
        }
         // преамбула
        	return; // уходим
        Save_123456:
        	adr_in_172301129_1 = adr_in_172301129_1 << 1;
        bitWrite(adr_in_172301129_1, 0, bitRead(data1_in_172301129_1, 15)); // проталкиваем принимаемые биты
        	data1_in_172301129_1 = data1_in_172301129_1 << 1;
        bitWrite(data1_in_172301129_1, 0, bitRead(data2_in_172301129_1, 15));
        	data2_in_172301129_1 = data2_in_172301129_1 << 1;
        bitWrite(data2_in_172301129_1, 0, bitRead(data3_in_172301129_1, 15));
        	data3_in_172301129_1 = data3_in_172301129_1 << 1;
        bitWrite(data3_in_172301129_1, 0, bitRead(data4_in_172301129_1, 15));
        	data4_in_172301129_1 = data4_in_172301129_1 << 1;
        bitWrite(data4_in_172301129_1, 0, bitRead(rand_in_172301129_1, 15));
        	rand_in_172301129_1 = rand_in_172301129_1 << 1;
        bitWrite(rand_in_172301129_1, 0, bitRead(data5_in_172301129_1, 15));
        	data5_in_172301129_1 = data5_in_172301129_1 << 1;
        bitWrite(data5_in_172301129_1, 0, bitRead(data6_in_172301129_1, 15));
        	data6_in_172301129_1 = data6_in_172301129_1 << 1;
        bitWrite(data6_in_172301129_1, 0, bitRead(data7_in_172301129_1, 15));
        	data7_in_172301129_1 = data7_in_172301129_1 << 1;
        bitWrite(data7_in_172301129_1, 0, bitRead(data8_in_172301129_1, 15));
        	data8_in_172301129_1 = data8_in_172301129_1 << 1;
        bitWrite(data8_in_172301129_1, 0, bitRead(CRC_in_172301129_1, 15));
        	CRC_in_172301129_1 = CRC_in_172301129_1 << 1;
        bitWrite(CRC_in_172301129_1, 0, bit_172301129_1);
        	
        {
            Prinimaem_172301129_1 ++;
        }
        	if (Prinimaem_172301129_1 == 176)  // приняли все данные?
        	
        {
            		CRC_172301129_1 = ((adr_in_172301129_1 + data1_in_172301129_1 + data2_in_172301129_1 + data3_in_172301129_1 + data4_in_172301129_1 + rand_in_172301129_1 + data5_in_172301129_1 + data6_in_172301129_1 + data7_in_172301129_1 + data8_in_172301129_1) xor 44111) + 1; // вычисляем контрольную сумму
            		if ((Svoy_signal_172301129_1) && (CRC_172301129_1 == CRC_in_172301129_1))  // все совпадает?
            		
            {
                			adr_172301129_1 = adr_in_172301129_1;
                			data1_172301129_1 = data1_in_172301129_1 xor rand_in_172301129_1; // расшифровываем данные
                			data2_172301129_1 = data2_in_172301129_1 xor rand_in_172301129_1;
                			data3_172301129_1 = data3_in_172301129_1 xor rand_in_172301129_1;
                			data4_172301129_1 = data4_in_172301129_1 xor rand_in_172301129_1;
                			data5_172301129_1 = data5_in_172301129_1 xor rand_in_172301129_1;
                			data6_172301129_1 = data6_in_172301129_1 xor rand_in_172301129_1;
                			data7_172301129_1 = data7_in_172301129_1 xor rand_in_172301129_1;
                			data8_172301129_1 = data8_in_172301129_1 xor rand_in_172301129_1;
                			data_ok_172301129_1 = true;
                		
            }
            Clear_123456:  // сброс данных
            		Svoy_signal_172301129_1 = false;
            		Prinimaem_172301129_1 = 50;
            		adr_in_172301129_1 = 0;
            		rand_in_172301129_1 = 0;
            		data1_in_172301129_1 = 0;
            		data2_in_172301129_1 = 0;
            		data3_in_172301129_1 = 0;
            		data4_in_172301129_1 = 0;
            		data5_in_172301129_1 = 0;
            		data6_in_172301129_1 = 0;
            		data7_in_172301129_1 = 0;
            		data8_in_172301129_1 = 0;
            		CRC_in_172301129_1 = 0;
            	
        }
    }
    in_old_172301129_1 = in_rf_172301129_1;
}
