MultipleOw
This example program shows you how to create an array of OW device structures, which can be very useful if you have more than one OW device connected to the bus.
' import modules... Imports DS18B20 ' temperature sensor module Imports OW ' one wire, used for search ' OW rom structure... structure OwRomId romID(8) as byte family as byte end structure ' program constants and variables... const MAX_ROM = 8 ' max number of likely Ow devices dim owDevices(MAX_ROM) as OwRomId ' array of rom ids dim deviceCount as byte = 0 ' number of devices ' device found event... Sub OnDeviceFound(command As Byte, family As Byte, ByRef romID() As Byte, ByRef abort As Boolean) Handles OW.OnSearch owDevices(deviceCount).romID = romID ' save rom ID owDevices(deviceCount).family = family ' save family deviceCount += 1 ' next End Sub ' main program entry point... Sub Main() OW.Search() Console.Write("Devices found : ",CStr(deviceCount),13,10) for deviceIndex as byte = 0 to deviceCount - 1 for index as byte = 0 to ubound(Ow.RomID) Console.Write("&H", Hex(owDevices(deviceIndex).RomId(index),2)," ") next console.write(13,10) next End Sub


