BS2 with PINK
wingclipper
Posts: 6
I am having trouble correlating variables from the webserver to use on the bs2 board..
example. i want to change the pause variable in a LED using the web variable of the pink server..
example. i want to change the pause variable in a LED using the web variable of the pink server..
Comments
There is no correlation involved. The PINK simply provides variables that you can include in your webpage as shown in the examples. The BS2 can read and write these variables. If a variable contains a number, the BS2 can read the variable value as a numeric value as described in the chapter on SERIN in the Stamp Editor's help files. If you're using a PAUSE statement, the time can be any expression including variables.
can't get teh LED to light...
nbvar VAR Byte
Baud CON 84
TX PIN 13
RX PIN 14
SEROUT TX, Baud, ["!NB0R01"]
SERIN RX, Baud, [nbvar]
SEROUT TX, Baud, ["!NB0SI"]
SERIN RX, Baud, [STR nbvar\11\CLS]
SEROUT TX, Baud, ["!NB0W01:100 " , CLS]
SEROUT TX, Baud, ["!NB0W02:", 150, CLS]
SEROUT TX, Baud, ["!NB0W03:", nbvar, CLS]
'PAUSE 500
DEBUG nbvar
DO
HIGH 2
PAUSE nbvar
LOW 2
PAUSE nbvar
LOOP
Like I said before, there's nothing wrong with the LED blink code. You just have to supply it with a valid value from the PINK.
What's an "!NB0SI" command? I can't find it in the PINK documentation.
IF the temperature is set to higher then the current temp, the red LED lit..
'Thermostat with PINK 1.0
'To remotely access a thermostat built on BS2 board with Pink Module
' {$STAMP BS2}
' {$PBASIC 2.5}
'Variables
x VAR Byte ' General purpose variable, byte.
degC VAR Byte ' Variable to hold degrees Celsius.
degF VAR Byte ' Variable to hold degrees Fahrenheit
settemp VAR Byte ' Variable to hold temperature set
storedtemp VAR Byte ' Comparison Variable for temperature
nbvar VAR Byte ' Variable to RX/TX PINK
'Pin Assignments
RX PIN 2 ' Serial Receieve Pin --> PINK.TX
TX PIN 3 ' Serial Transmit Pin --> PINK.RX
'Constants Assignments
Baud CON 84 ' 9600 bps (BS2
'Initializations
SEROUT 12, 84, [12,22] 'Initialize LCD and clear LCD
' Note: DS1620 has been preprogrammed for mode 2.
OUTS=%0000000000000000 ' Define the initial state of all pins,
'FEDCBA9876543210
DIRS=%0000000000000000 ' as low outputs.
HIGH 6 ' Select the DS1620.
SHIFTOUT 5, 7, LSBFIRST, [238] ' Send the "start conversions" command.
LOW 6
DEBUG "Initialization Finished",CR
PAUSE 1000
'DEBUG "Please set the temperature",CR
'DEBUGIN DEC2 settemp
'PAUSE 1000
DEBUG CLS
Main:
DO
GOSUB Push_Button
GOSUB Get_Temperature
LOOP
Push_Button:
IF IN11 = 1 THEN 'Monitor pushbutton for setting temperature
settemp = settemp + 1
ENDIF
IF IN10 = 1 THEN
settemp = settemp - 1
ENDIF
RETURN
Get_Temperature:
HIGH 6 ' Select the DS1620.
SHIFTOUT 5, 7, LSBFIRST, [170] ' Send the "get data" command.
SHIFTIN 5, 7, LSBPRE, [x] ' Get the data.
LOW 6 ' End the command.
degC = x / 2
degF= degC*9/5 + 32 ' Convert the data to Fahrenheit.
storedtemp = degF
'Display Temperature on DEBUG,LCD, and transmit to website
SEROUT 12, 84, [12,22] 'Intialize LCD and clear LCD
SEROUT 12, 84, [128, DEC3 degC, " C*", 'Display Temperature on LCD
134, "Temp is ",
154, "set to:", DEC2 settemp, "F",
148, DEC3 degF, " F*"]
DEBUG HOME
SEROUT TX, Baud, ["!NB0R00"] ' Send Command To Read Variable 01
SERIN RX, Baud, 100, Timeout, [DEC nbvar] ' Get Data With Timeout
DEBUG "Variable 00: ", DEC nbvar, CR ' Display Byte In Decimal
settemp = nbvar
IF settemp < storedtemp THEN
HIGH 0
LOW 1
ENDIF
IF settemp > storedtemp THEN
LOW 0
HIGH 1
ENDIF
IF settemp = storedtemp THEN 'Heat/Cold Programming
LOW 0
LOW 1
ENDIF
SEROUT TX, Baud, ["!NB0W00:", DEC settemp, CLS]
SEROUT TX, Baud, ["!NB0W01:", DEC degF, CLS]
SEROUT TX, Baud, ["!NB0W02:", DEC degC, CLS]
DEBUG ? degC 'Display All Variables on DEBUG
DEBUG ? degF
DEBUG ? settemp
DEBUG ? storedtemp
DEBUG ? IN13
DEBUG ? IN11
DEBUG ? IN10
DEBUG ? IN9
DEBUG ? IN8
PAUSE 250
RETURN
Timeout:
DEBUG "Communication Timeout!" ' Serial Timeout
END