$regfile = "m16def.dat"
$crystal = 1000000
Config Kbd = Portd , Debounce = 30
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7 , Rs = Portb.3 , E = Portb.2
Deflcdchar Print , 16 , 32 , 32 , 32 , 32 , 32 , 32 , 32    ' replace ? with number (0)
Dim A As Byte
Dim B As Single
Dim Key As Byte
Dim C As Single
Dim D As Single
Dim E As Byte
Dim F As Byte
Dim Flag As Byte
Dim H As Single
Dim H2 As Single
Cls
Cursor Off
Locate 2 , 1
Lcd "avrprojects.info"
E = 0
B = 0
Flag = 0
H = 1
H2 = 0
Q:
Waitms 200
'B = 0
A = Getkbd()
If A > 15 Then
      Goto Q
   Else
    Key = Lookup(a , Dta)
    If Key <= 9 And Flag = 0 Then
        D = 0
        B = 10 * B
        B = B + Key
    If E = 0 Then C = B
    If E = 1 Then D = B
            Cls : Lcd B
    Elseif Key <= 9 And Flag = 1 Then
            Cls
            H = H * 0.1
            H2 = H * Key
              B = B + H2
              Lcd B
              If E = 0 Then C = B
              If E = 1 Then D = B
      Elseif Key = 10 Then
            Cls
            Flag = 0
            F = 1
            E = 1
            B = 0
      Elseif Key = 11 Then
            Cls
            Flag = 0
            E = 1
            F = 2
            B = 0
      Elseif Key = 12 Then
            Cls
            Flag = 0
            E = 1
            F = 3
            B = 0
      Elseif Key = 15 Then
             Flag = 1
      Elseif Key = 13 Then
            Cls
            Flag = 0
            E = 0
            B = 0
            H = 1
      Elseif Key = 14 Then
          If E = 1 Then
               Cls
             Select Case F
               Case 1 :
                  B = C / D
               Case 2:
                  B = C * D
               Case 3:
                  B = C - D
            End Select
          Lcd B
       End If
     End If
 End If
Locate 2 , 1
Lcd "avrprojects.info"
 Goto Q
End
Dta:
Data 7 , 8 , 9 , 10 , 4 , 5 , 6 , 11 , 1 , 2 , 3 , 12 , 13 , 0 , 14 , 15