Shop OBEX P1 Docs P2 Docs Learn Events
BS1 and Humidity Sensor SHT1x (SHIFTIN and SHIFTOUT on BS1) — Parallax Forums

BS1 and Humidity Sensor SHT1x (SHIFTIN and SHIFTOUT on BS1)

DonivanDonivan Posts: 23
edited 2004-11-11 21:30 in BASIC Stamp
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

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-11-11 21:30
    You can certainly bit-bang SHIFTIN/SHIFTOUT code for the BS1. The next trick is converting the data to a usable value. You may want to do that externally and just deal with the raw data, especially since you're doing a single comparison.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
Sign In or Register to comment.