//disable timestep Timestep OFF //get temperature for the first time CALL CALCTEMP VAR2 = VAR1 LABEL LOOP //get temperature and put it into VAR1 CALL CALCTEMP IF VAR1 != $VAR2 Then //previous mesurement differs from current mesurement IF VAR3 > 0005 Then //time since last speech output is 5sec minimum VAR3 = 0 CALL SAYTEMP VAR2 = VAR1 ELSE //time since previous speech output was too short END IF END IF //wait 1 second between each mesurement (and increase counter VAR3) WAIT 1000 VAR3 = VAR3 + 1 GOTO LOOP //Sub Saytemperature: says the current temperature. (make connection) SUB SAYTEMP CONNECT TCP,127.0.0.1,9999 END SUB //Sub Saytemperature: says the current temperature. (connection made) SUB EVENT_CONNECTION_ESTABLISHED //Speech Server running! clear error LED CLEARIO 01 SEND "The temperature changed to $VAR1 degrees" DISCONNECT END SUB //Sub Saytemperature: says the current temperature. (connection not possible) SUB EVENT_CONNECTION_ERROR //Speech Server not running! - set error LED SETIO 01 END SUB //Sub CalcTemp: calculates the current temperature (put into VAR1) SUB CALCTEMP TEXTVAR = "(($AD02*0.0196)/0.02)-24.1" VAR1 = $CALC(TEXTVAR) END SUB