$regfile = "attiny2313.dat" $crystal = 1000000 Config Portb = &B11111100 Config Portd = &B1110000 Config Lcdpin = Pin , Db4 = Portb.5 , Db5 = Portb.4 Config Lcdpin = Pin , Db6 = Portb.3 , Db7 = Portb.2 Config Lcdpin = Pin , E = Portb.6 , Rs = Portb.7 Config Lcd = 16 * 2 Cls : Cursor Off Config Debounce = 1 Declare Sub Encode Declare Sub Lcdisplay Declare Sub Datashift Dim C As Byte Dim F As Long Dim S As Integer C = &B1100111 F = 1000 S = 1 Portb = 3 Portd = 15 A Alias Pinb.0 B Alias Pinb.1 S10 Alias Pind.0 S100 Alias Pind.1 S1000 Alias Pind.2 Call Lcdisplay Call Datashift Do Debounce A , 0 , Encode , Sub Loop End Sub Encode If B = 1 Then Incr F S = 1 If S10 = 0 Then F = F + 9 : S = 10 End If If S100 = 0 Then F = F + 99 : S = 100 End If If S1000 = 0 Then F = F + 999 : S = 1000 End If If F > 10000 Then F = 10000 Call Lcdisplay Call Datashift Else Decr F S = 1 If S10 = 0 Then F = F - 9 : S = 10 End If If S100 = 0 Then F = F - 99 : S = 100 End If If S1000 = 0 Then F = F - 999 : S = 1000 End If If F < 0 Then F = 0 Call Lcdisplay Call Datashift End If End Sub Sub Lcdisplay Cls Lcd "FREQ " ; F ; "Hz" Lowerline Lcd "STEP " ; S ; "Hz" End Sub Sub Datashift Set Portd.4 Shiftout Portd.5 , Portd.6 , C , 3 , 7 Shiftout Portd.5 , Portd.6 , F , 3 , 26 Reset Portd.4 Set Portd.4 End Sub