'{$STAMP BS2} 'Basic Stamp Activity Board StampPlot V3 Example 'Martin Hebel -- SelmaWare Solutions -- 3/13/02 '********************************************** SFreq VAR Word SDur VAR WORD Spkr CON 11 Pot CON 7 RCPot VAR WORD SFreq=2000 SDur=500 X VAR Byte Loop: GOSUB ReadPlot GOSUB UpdatePlot GOSUB P8Check GOSUB P9Check GOSUB P10Check GOSUB P11Check Goto Loop '************** ' These 4 routines can perform an action when I/O Acitve (low,0). P8Check: 'Set to sound speaker IF IN8=1 THEN P8Done DEBUG "!STAT Sounding Speaker",CR FREQOUT Spkr,SDur,SFreq P8Done: Return P9Check: 'Set to Reset Plot IF IN9=1 THEN P9Done DEBUG "!STAT Resetting Plot",CR DEBUG "!RSET",CR P9Done: Return P10Check: 'Set to sound Alarm on Stampplot IF IN10=1 THEN P10Done DEBUG "!STAT Nuclear Siren!",CR DEBUG "~PWAV NRALARM.WAV",CR P10Done: Return P11Check: 'Set to blink P8 LED IF IN11=1 THEN P11Done DEBUG "!STAT Blinking P8",CR For X = 0 to 10 TOGGLE 8 Pause 50 Next HIGH 8 P11Done: Return ' ***************** ' Read the values from the plot ReadPlot: ' Get direction of IO as digital coverted to analog (DAC) DEBUG "!READ [(c11)(c10)(c9)(c8),DAC]",CR SERIN 16,84,200,Timeout,[DEC DIRC] PAUSE 100 ' Read output states as digital converted to analog DEBUG "!READ [(o11)(o10)(o9)(o8),DAC]",CR SERIN 16,84,200,Timeout,[DEC OUTC] PAUSE 100 ' Read speaker frequency from slider DEBUG "!READ (FREQ)",CR SERIN 16,84,200,Timeout,[DEC SFreq] PAUSE 100 ' Read speaker duration from slider DEBUG "!READ (DUR)",CR SERIN 16,84,200,Timeout,[DEC SDur] Timeout: Pause 100 Return '***************** ' Send data to plot for indication UpdatePlot: HIGH 7 'Read Pot Pause 10 RCTIME Pot,1,RCPot DEBUG DEC RCPot,CR 'Plot (and update) analog DEBUG IBIN4 INC,CR 'Plot (and update) digital Return