|
我有找到SRF08的程式,要如何改為SRF02
'{$STAMP BS2px}
' {$PBASIC 2.5}
'***********************************************************
'** **
'** I2C Routines for the Basic Stamp BS2p **
'** Controlling SP03 Speech Synthesizer **
'** **
'** Copyright 2002 - Devantech Ltd **
'** Commercial use of this software is prohibited **
'** Private and educational use only is permitted **
'** **
'** Written by Gerald Coe - August 2002 **
'** **
'***********************************************************
SCL CON 10 ' I2C clock
SDA CON 9 ' I2C data
NOP CON 0 ' No Operation command
status VAR Byte
Main:
' The following shows how easy it is to use the BS2p with the Speech Module,
' a single line command is all that is required to speak any of the 30
' pre-loaded phrases. The example below shows how to speak phrase number 21.
GOSUB wait4shutup ' wait for last phrase to finish speaking
I2COUT SDA, $C4, 0, [21] ' speak phrase number 21 and flush internal buffer
' You can also send your own Text to Speech messages to the module to be spoken.
' The first data byte is the command, in this case a NOP, since we just need to
' load the buffer. The 2nd value is Volume (0-7) which works backwards - 0 is
' loudest and 7 is quiet. The 3rd value is Pitch (0-7) which it is best to just
' try it and see. The 4th value is Speed (0-3) with 3 being fastest.
' You then place the text you wish spoken in inverted comma's and finally
' the 0 (NULL).
GOSUB wait4shutup ' wait for last phrase to finish speaking
I2COUT SDA, $C4, 0, [NOP, 0,5,3, "Hello Gerry, How are u today", 0]
' The above loads the modules internal buffer. You then need to send a command to
' speak the phrase you just loaded.
I2COUT SDA, $C4, 0, [$40] ' The speak command also flushes the buffer
' You can also load the buffer in smaller, multiple fragments if you wish to.
' Up to 85 bytes can be stored in the SP03's internal buffer, that's 81 characters
' plus the Volume, Pitch, Speed and terminating NULL.
GOSUB wait4shutup ' wait for last phrase to finish speaking
I2COUT SDA, $C4, 0, [NOP, 0,5,3, "This is a test on how"]
I2COUT SDA, $C4, 0, [NOP, " to send a message as"]
I2COUT SDA, $C4, 0, [NOP, " a number of smaller pieces", 0]
I2COUT SDA, $C4, 0, [$40] ' Speak the phrase.
' And thats it.
' The following completes the program so that you can run it.
forever:'GOTO forever
wait4shutup:
I2CIN SDA, $C4, 0, [status]
'DEBUG "Status:",DEC status,CR
IF status>0 THEN wait4shutup
RETURN |
|