;********************************************************************* ; Program for Design Idea #2411: "Connect a modem to a Basic ; Stamp," EDN, Sept 16, 1999, pg 194. ; ; http://www.ednmag.com/ednmag/reg/1999/091699/designideas.htm#19di2 ; ;********************************************************************* 'This setup sends data from a stamp modem in auto answer mode to 'a sending computer 'STPMEM data transfer '2/1/99 x var byte(18) 'data string y var word 'BASIC Stamp baud rate d1 var byte 'StampMEM data I/O, 1 or 0 d2 var byte 'StampMEM high byte location, 0 to 255 d3 var byte 'StampMEM low byte location, 0 to 255 d4 var byte 'StampMEM number of data bytes y=396 'BS2 set @2400 baud aa: 'Place your code here to read sensors and save data to StampMEM and afterwards 'place modem in answer mode. Update sensor date as required allowing time space 'for modem to answer incoming calls. d1=1:d2=0:d3=0:d4=16 'StampMEM read controls low 3 'activate modem and send commands input 4 serout 1,y,["ATV0",cr] serin 2,y,[dec x] debug cls,dec x,cr serout 1,y,["AT S0=1",cr] '10th ring answer serin 2,y,[dec x] debug dec x,cr serout 1,y,["AT S14=2",cr] 'modem in auto answer serin 2,y,[dec x] debug dec x,cr debug "Modem now in answer mode...",cr serin 2,y,[dec x] debug dec x,cr serin 2,y,60000,aa,[dec x] 'goback and read sensors every minute debug dec x,cr if x=10 then bb debug "Bad connection...",cr pause 10000 goto cc bb: pause 10000 serout 1,y,["type now..",10,cr] 'request from remote PC terminal serin 2,y,[wait ("start")] debug "sending data...",cr serout 1,y,[10,cr] dd: serout 0,240,[d1,d2,d3,d4] 'read data from StampMEM serin 0,240,[str x\16] debug str x serout 1,y,[str x\16] 'send data to modem d3=d3+16 if d3=0 then ee goto dd ee: d2=d2+1 if d2=4 then ff goto dd ff: serout 1,y,[10,cr,"That's enough! Hangup now...",10,cr] serin 2,y,[dec x] debug dec x,cr cc: high 4 'reset modem pause 20 low 4 pause 5000 goto aa