$crystal = 10000000 Dim Tempmsb As Byte Dim Templsb As Byte Dim Tempneg As Integer Dim D As Byte Dim N As Byte , L As Byte , W As Byte Dim A As Integer Dim B1 As Byte Dim X As Integer Declare Sub Showdigits(a As Integer) Declare Sub Startconvert() Declare Sub Readtemp(tempmsb As Byte) P1 = 0 P3 = 0 P1.4 = 1 Call Startconvert Waitms 10000 Deib: Call Readtemp(tempmsb) Tempmsb = Tempmsb - 3 Select Case Tempmsb Case 0 To 99 : Call Showdigits(tempmsb) 'temp >0 show temp on display Case 100 To 127 : Call Showdigits( -88) 'temp > 99.5 show -- on display Case 128 To 245 : Call Showdigits( -88) 'temp < -9.5 show -- on dsiplay Case 246 To 255 : Tempneg = Tempmsb - 245 Tempneg = 0 - tempneg Call Showdigits(tempneg) Waitms 10000 End Select Goto Deib Sub Showdigits(a As Integer) If A < 0 Then P1.4 = 0 Else P1.4 = 1 ' enable negative sign A = Abs(a) If A < 10 Then B1 = &HFF Shiftout P1.2 , P1.0 , B1 , 0 B1 = Lookup(a , Digits) Shiftout P1.3 , P1.1 , B1 , 0 ' show Exit Sub End If If A >= 10 Then Dim S As String * 4 S = Str(a) B1 = Val(mid(s , 1 , 1)) B1 = Lookup(b1 , Digits) Shiftout P1.2 , P1.0 , B1 , 0 B1 = Val(mid(s , 2 , 1)) B1 = Lookup(b1 , Digits) Shiftout P1.3 , P1.1 , B1 , 0 Exit Sub End If End Sub Sub Startconvert() I2cstart I2cwbyte &H90 I2cwbyte &HEE I2cstop End Sub Sub Readtemp(tempmsb As Byte) '------------- I2cstart I2cwbyte &H90 'send adress byte Waitms 150 I2cwbyte &HAA 'send register byte waitms 150 I2cstop I2cstart I2cwbyte &H91 'read register waitms 150 I2crbyte Tempmsb , Ack waitms 150 I2crbyte Templsb , Nack waitms 150 I2cstop End Sub Digits: 'Data 17 , 221 , 131 , 137 , 93 , 41 , 33 , 157 , 1 , 13 Data 136 , 238 , 193 , 196 , 166 , 148 , 144 , 206 , 128 , 132