Having Trouble Converting Code from Basic To Javelin - For Sound Module
JoeSchmoe
Posts: 2
I have just switched over to Javelin from PBasic and am having trouble with the "Sound Module" that Parallax supplied with user instructions that are only in PBasic.
Their PBasic program is listed below:
x var byte ‘loop counter
Init: pause 500 ‘wait for power up
serout 4,84+$8000,[noparse][[/noparse]"!SM0N"] 'Enable recording
pause 500 'Wait a little time
Start: for x = 0 to 3 'For 3 different addresses:
serout 4,84+$8000,[noparse][[/noparse]"!SM0R",(X*5)] 'Record a message
pause 1950 'for 1.95 seconds
serout 4,84+$8000,[noparse][[/noparse]"!SM0E"] 'then End recording
pause 1000 'and one second later
serout 4,84+$8000,[noparse][[/noparse]"!SM0P",(X*5)] 'Play that message back
pause 2000 'Wait for message
next 'repeat until done
for x = 0 to 3
serout 4,84+$8000,[noparse][[/noparse]"!SM0P",(X*5)] ' Play 3 messages back
pause 2000
next
end
I wrote a small program to try to communicate the first command and nothing happened.
import stamp.core.*;
public class EnableRecording { // COM Port (9-pin serial)
final static int SERIAL_TX_PIN = CPU.pin4; // 2
static Uart txUart = new Uart( Uart.dir mit, SERIAL_TX_PIN, Uart.dontInvert,
Uart.speed9600, Uart.stop1 );
public static void main(){
CPU.delay(500);
txUart.sendString("!SMON");
} // end main
}
Parallax's manual for the "Sound Module" is located at:
http://www.parallax.com/dl/docs/prod/appmod/soundmodule.pdf
Their PBasic program is listed below:
x var byte ‘loop counter
Init: pause 500 ‘wait for power up
serout 4,84+$8000,[noparse][[/noparse]"!SM0N"] 'Enable recording
pause 500 'Wait a little time
Start: for x = 0 to 3 'For 3 different addresses:
serout 4,84+$8000,[noparse][[/noparse]"!SM0R",(X*5)] 'Record a message
pause 1950 'for 1.95 seconds
serout 4,84+$8000,[noparse][[/noparse]"!SM0E"] 'then End recording
pause 1000 'and one second later
serout 4,84+$8000,[noparse][[/noparse]"!SM0P",(X*5)] 'Play that message back
pause 2000 'Wait for message
next 'repeat until done
for x = 0 to 3
serout 4,84+$8000,[noparse][[/noparse]"!SM0P",(X*5)] ' Play 3 messages back
pause 2000
next
end
I wrote a small program to try to communicate the first command and nothing happened.
import stamp.core.*;
public class EnableRecording { // COM Port (9-pin serial)
final static int SERIAL_TX_PIN = CPU.pin4; // 2
static Uart txUart = new Uart( Uart.dir mit, SERIAL_TX_PIN, Uart.dontInvert,
Uart.speed9600, Uart.stop1 );
public static void main(){
CPU.delay(500);
txUart.sendString("!SMON");
} // end main
}
Parallax's manual for the "Sound Module" is located at:
http://www.parallax.com/dl/docs/prod/appmod/soundmodule.pdf
Comments
for 500 msec (eg. pause 500) use CPU.delay(5250);
If that doesn't do the trick, try using Uart.invert
instead of Uart.dontInvert
regards peter
the command is !SM0N, not !SMON
(a zero, not a capital o)
From thie listing it appears you type a capital o.
regards peter
·
Joe