BS1 and Humidity Sensor SHT1x (SHIFTIN and SHIFTOUT on BS1)
Donivan
Posts: 23
I want to build a simple humidity-controlled relay to start a fan in the basement when humidity rises to a certain level. Is it possible to use the BS1 and the Humitity/Temperature sensor SHT1x together? I notice the code snippets to access the SHT1x uses SHIFTIN and SHIFTOUT, which are not available on the BS1, and all the code samples are geared towards the BS2 chip. I poked around and found some subroutines that claim to do the same thing on the BS1:
ShiftIn:
DIRS = %00000001 'Set Clock pin as output and Data pin as input
FOR Count = 1 TO 8
PULSOUT CLK,1 'Preclock the data
Value = Value * 2 + DATA 'Shift result left and grab next 'data bit
NEXT Count
return
ShiftOut:
DIRS = %00000011 'Set Clock and Data pins as outputs
Value = 125 'Value to be shifted out
FOR Count = 1 TO 8
DATA = BIT7 'Send out MSB of B0
PULSOUT CLK,1 'Clock the data
B0 = B0 * 2 'Shift the value left; note that this causes us
'to lose the value
NEXT Count 'when we're done shifting
return
Is this a viable solution or should I just use the BS2?? What else might I run up against?
Thanks,
Donivan
ShiftIn:
DIRS = %00000001 'Set Clock pin as output and Data pin as input
FOR Count = 1 TO 8
PULSOUT CLK,1 'Preclock the data
Value = Value * 2 + DATA 'Shift result left and grab next 'data bit
NEXT Count
return
ShiftOut:
DIRS = %00000011 'Set Clock and Data pins as outputs
Value = 125 'Value to be shifted out
FOR Count = 1 TO 8
DATA = BIT7 'Send out MSB of B0
PULSOUT CLK,1 'Clock the data
B0 = B0 * 2 'Shift the value left; note that this causes us
'to lose the value
NEXT Count 'when we're done shifting
return
Is this a viable solution or should I just use the BS2?? What else might I run up against?
Thanks,
Donivan
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office