Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001
Page 55
' -----[ Main Code ]------------------------------------------------------------
'
Main:
DEBUG CLS
DEBUG "DS2980 1 -Wire Pot Demo", CR, CR
DEBUG "Pot Setting... ",CR
DEBUG "RC Value...... "
Demo_Pot:
FOR potLevel = 255 TO 0 STEP 5
DEBUG Home, CR, CR, "Pot Setting... ", DEC potLevel, " ", CR
' send new level to pot
OWOUT OWpin, OW_FERst, [MatchROM, STR romData\8, WrPot, potLevel]
OWIN OWpin, 0, [temp] ' read new level back
IF (temp <> potLevel) THEN Pot_Error ' check for correct receipt
OWOUT OWpin, OW_BERst, [Release] ' release new value
PAUSE 100
HIGH RCpin ' dicharge RC cap
PAUSE 1
RCTIME RCpin, 1, rcValue ' read pot
DEBUG "RC Value...... ", DEC rcValue, " "
PAUSE 500
NEXT
GOTO Main
END
' -----[ Subroutines ]----------------------------------------------------------
'
Pot_Error:
DEBUG CLS
DEBUG "Error -- could not set pot"
END