$regfile = "attiny2313.dat" $crystal = 4000000 $hwstack = 32 $swstack = 8 $framesize = 24 Config 1wire = Portd.3 'Вход считывания ключа Config Pind.4 = Input Config Pind.5 = Input Config Pind.6 = Input Config Pinb.0 = Input Config Portb.1 = Output Config Portb.2 = Output Config Portb.3 = Output Config Portb.4 = Output Config Pinb.5 = Input Config Portb.6 = Output Config Portb.7 = Output Config Debounce = 75 '////////////i-button Dim Eepromadres As Byte Dim Eeprom As Byte Dim Register_number(8) As Byte Dim Button_number(8) As Byte Dim Button_weryfikacija As Byte Dim Ibutton_ok As Bit Dim Temp1 As Byte Dim Temp2 As Byte 'Dim Status As Byte Declare Sub Registracija() Declare Sub Autoryzacija() '////////////end i-button '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Dim Bolt As Integer Config Timer0 = Timer , Prescale = 256 Enable Timer0 On Timer0 Int_1 Timer0 = 31285 Stop Timer0 Bolt = 0 '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< If Pind.4 = 0 Then Portb.4 = 1 Call Registracija End If '///////////////EEPROM 'Readeeprom Eeprom , 127 'If Eeprom <> 1 Then ' Call Registracija 'End If '///////////END EEPROM Dim Wtime As Byte Wtime = 255 'Debounce Portb.3 , 0 , Stat , Sub Portb.3 = 1 Dim W As Integer On Int0 Button Enable Int0 If Portb.3 = 1 Then Enable Interrupts 'разрешаем прерывания Else Disable Interrupts End If 1wreset If Err = 0 Then Call Autoryzacija End If Do If W = 2 And Portb.3 = 1 Then Set Portb.1 Set Portb.4 Set Portb.6 W = 0 End If If W = 3 And Portb.3 = 1 Then Set Portb.2 Set Portb.4 Set Portb.7 W = 0 End If If W = 1 And Portb.3 = 1 Then Set Portb.1 Set Portb.2 Set Portb.4 Set Portb.6 Set Portb.7 W = 0 End If If Bolt = 4 Then Reset Portb.4 End If If Bolt = 6 Then Reset Portb.6 Reset Portb.7 Bolt = 0 Stop Timer0 End If Idle Loop End Button: 'здесь мы в цикле сканируем все подключенные кнопки Do If Pind.5 = 0 Then W = 1 End If If Pind.6 = 0 Then W = 2 End If If Pinb.0 = 0 Then W = 3 End If Loop Until W <> 0 'если дребезг помешал вычислению нажатой кнопки, повторяем Waitms 100 If Bolt > 0 Then Pulseout Portb , 3 , 1500 'мигнем светодиодом Else Start Timer0 End If Gifr = 64 'сброс флага прерывания Return Int_1: Timer0 = 31285 Incr Bolt Return '#######################i-Button#################################### ' '______________________________________________________________________________________________________________ Sub Registracija 'ПРОЦЕДУРА РЕГИСТРАЦИИ IButton For Temp2 = 1 To 3 'Reset Led 'Set Led Next Temp2 Eepromadres = 1 Do Register_number(1) = 1wsearchfirst() If Err = 0 Then For Temp1 = 1 To 8 Writeeeprom Register_number(temp1) , Eepromadres Incr Eepromadres Next Temp1 'Reset Led 'Set Led End If If Eepromadres > 80 Then For Temp2 = 1 To 4 'Reset Led 'Set Led Next Temp2 Eeprom = 1 Writeeeprom Eeprom , 127 Exit Do End If Loop End Sub '______________________________________________________________________________________________________________ Sub Autoryzacija Register_number(1) = 1wsearchfirst() If Err = 0 Then Eepromadres = 1 For Temp2 = 1 To 10 For Temp1 = 1 To 8 Readeeprom Button_number(temp1) , Eepromadres If Button_number(temp1) = Register_number(temp1) Then Button_weryfikacija = Button_weryfikacija + 1 Else Button_weryfikacija = 0 End If Incr Eepromadres Next Temp1 If Button_weryfikacija = 8 Then Ibutton_ok = 1 Toggle Portb.3 Button_weryfikacija = 0 Exit Sub End If Next Temp2 End If End Sub '______________________________________________________________________________________________________________