' Primer branja identifikacije termometra $regfile = "m8515.dat" '$regfile = "m16def.dat" '$regfile = "attiny2313.dat" $crystal = 11059200 Config 1wire = Portb.7 Config Lcd = 16 * 2 'Config Lcdpin = Pin , Db7 = Portc.7 , Db6 = Portc.6 , Db5 = Portc.5 , Db4 = Portc.4 , E = Portc.2 , Rs = Portc.1 'Config Lcdpin = Pin , Db7 = PortB.7 , Db6 = PortB.6 , Db5 = PortB.5 , Db4 = PortB.4 , E = PortB.3 , Rs = PortB.2 'Config Lcdpin = Pin , Db7 = PortB.7 , Db6 = PortB.6 , Db5 = PortB.5 , Db4 = PortB.4 , E = PortB.3 , Rs = PortB.2 Config Lcdpin = Pin , Db7 = Portd.7 , Db6 = Portd.6 , Db5 = Portd.5 , Db4 = Portd.4 , E = Portd.2 , Rs = Portd.1 Cls Lcd "DS1820-4.bas" Cursor Off Noblink Wait 1 Cls Dim X(9) As Byte , A1 As Byte Dim I As Byte 1wreset 1wwrite &H33 Waitms 250 ' ukaz, ki sprozi predstavitev ID stevilke ' ReadRom: ' This command can only be used when there is one slave on the bus. ' It allows the bus master to read the slave's 64bit romcode without ' using searchrom procedure ' 1wreset X(1) = 1wread(8) ' preberi vrednost vsakega byta v polje 1wreset ' now we have 8 byte serial number in bytes Ba(1) to Ba(8) ' let as disply it on lcd ' pocakaj 250 ms Lowerline For I = 1 To 8 Lcd Hex(x(i)) Next Upperline Locate 1 , 14 Lcd Hex(x(9)) 'For A1 = 1 To 10 ' Shiftlcd Left ' Wait 1 'Next ' Preverjanje sprejetega telegrama If Crc8(x(1) , 9) = 0 Then Lcd "K" ' Šele po preverjanju bi morali prikazati temperaturo uporabniku! Else Lcd "N" End If End ' Dobili smo recimo Data &H10 , &HF1 , &HE9 , &H4D , &H00 , &H08 , &H00 , &H9C Data &H10 , &HE1 , &HF4 , &H4B , &H01 , &H08 , &H00 , &HF5 Data &H10 , &H53 , &H96 , &H4B , &H01 , &H08 , &H00 , &H0E