'************************************ '4x3 Tastatur an Relaisplatine 'mit 3 Ziffern Relais Ein-/ Ausschalten '011 = Platine 0, Relais 1, ein '020 = Platine 0, Relais 2, aus '------------------------------------ $regfile "8515def.dat" $crystal = 4000000 '$include "ac_lcd.inc" Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7 , E = Portb.3 , Rs = Portb.2 Config Lcd = 24 * 2 Cls '********* Code ************* Config Debounce = 150 ' Defaultwert erweitern Config Porta = Input 'Config Portb = Output Config Portc = Output Ddrd = &H0F 'PD7-PD4 Input; PD3-PD0 output Portd = &HFF 'mit intern. pullup Dim Column As Byte Dim Row As Byte Dim Key As Byte 'Variable mit Key-Nr Const Anz1 = "Status Rel.:" Const Anz2 = "0=aus/1=ein" Const Anz3 = "87654321" Portc = 0 'alles Relais aus Locate 1 , 1 : Lcd Anz1 Locate 1 , 14 : Lcd Anz3 Do For Column = 0 To 2 If Column = 0 Then Reset Portd.0 If Column = 1 Then Reset Portd.1 If Column = 2 Then Reset Portd.2 'If Column = 3 Then Reset Porta.3 For Row = 4 To 7 Select Case Row Case 4 : Debounce Pind.7 , 0 , Calc_key , Sub Case 5 : Debounce Pind.6 , 0 , Calc_key , Sub Case 6 : Debounce Pind.5 , 0 , Calc_key , Sub Case 7 : Debounce Pind.4 , 0 , Calc_key , Sub End Select Next Portd = &HFF Next Locate 2 , 0 : Lcd Anz2 Locate 2 , 14 : Lcd Bin(portc) Loop End Calc_key: Select Case Row Case 4 : Key = Column + 1 Case 5 : Key = Column + 4 Case 6 : Key = Column + 7 Case 7 : Key = Column + 10 End Select 'Lcd Key 'anzeigen der Tasten Nr - nur kontrolle - Portd = Not Key Gosub Relais Return Relais: 'Cls Key = Key - 1 '1 abziehen damit Relais an Port 0 gescgaltet wird Toggle Portc.key Key = Key + 1 '1 addieren dass Anzeige stimmt 'Lcd "Relais " ; Bin(portc) Return