easy serial pc to bs2
walkin79
Posts: 29
' {$STAMP BS2}
' {$PBASIC 2.5}
' This program accepts the numbers 1 & 2 as commands to beep.
' Other values produce an error beep.
' The circuit uses a piezo speaker on pin 9.
'
Pin Assignments
INPUT_PIN CON 16
BEEPER CON 9
light CON 13
'
Constant Assignments
BAUDMODE CON 16468
'
Variable Assignments
Command VAR Byte
Counter VAR Nib
Main:
DO
GOSUB GetInput
LOOP
END
' Receives input from some external source
GetInput:
SERIN INPUT_PIN, BAUDMODE, [Command]
GOSUB TakeAction
RETURN
TakeAction: ' Determines what to do based on result of GetInput
SELECT Command
CASE "1"
GOSUB Task1
RETURN
CASE "2"
GOSUB Task2
RETURN
CASE "3"
GOSUB Task3
RETURN
ENDSELECT
Task1:
FOR Counter = 1 TO 1
HIGH 13
PAUSE 500
LOW 13
NEXT
RETURN
Task2:
FOR Counter = 1 TO 1
HIGH 13
PAUSE 200
LOW 13
PAUSE 200
HIGH 13
PAUSE 200
LOW 13
NEXT
RETURN
Task3:
FOR Counter = 1 TO 1
HIGH 13
PAUSE 200
LOW 13
PAUSE 200
HIGH 13
PAUSE 200
LOW 13
PAUSE 200
HIGH 13
PAUSE 200
LOW 13
NEXT
RETURN
at the command prompt type
MODE COM3 BAUD=96 PARITY=N DATA=8 STOP=1
press enter
then type
ECHO 3 >COM3
press enter
the bs2 code above allows you to sent a 1 2 or 3 to the ps2 from pc serail connection
blinking a light 1 2 or 3 times
change com3 to whatever com the bs2 is on
change echo 3 >com3 to echo 2 >com3
or echo 1 >com3
with 8 bit data you can use 0-9 commands
if anyone knows how to receive serial input from the bs2 i could use it, the simpler the better
' {$PBASIC 2.5}
' This program accepts the numbers 1 & 2 as commands to beep.
' Other values produce an error beep.
' The circuit uses a piezo speaker on pin 9.
'
Pin Assignments
INPUT_PIN CON 16
BEEPER CON 9
light CON 13
'
Constant Assignments
BAUDMODE CON 16468
'
Variable Assignments
Command VAR Byte
Counter VAR Nib
Main:
DO
GOSUB GetInput
LOOP
END
' Receives input from some external source
GetInput:
SERIN INPUT_PIN, BAUDMODE, [Command]
GOSUB TakeAction
RETURN
TakeAction: ' Determines what to do based on result of GetInput
SELECT Command
CASE "1"
GOSUB Task1
RETURN
CASE "2"
GOSUB Task2
RETURN
CASE "3"
GOSUB Task3
RETURN
ENDSELECT
Task1:
FOR Counter = 1 TO 1
HIGH 13
PAUSE 500
LOW 13
NEXT
RETURN
Task2:
FOR Counter = 1 TO 1
HIGH 13
PAUSE 200
LOW 13
PAUSE 200
HIGH 13
PAUSE 200
LOW 13
NEXT
RETURN
Task3:
FOR Counter = 1 TO 1
HIGH 13
PAUSE 200
LOW 13
PAUSE 200
HIGH 13
PAUSE 200
LOW 13
PAUSE 200
HIGH 13
PAUSE 200
LOW 13
NEXT
RETURN
at the command prompt type
MODE COM3 BAUD=96 PARITY=N DATA=8 STOP=1
press enter
then type
ECHO 3 >COM3
press enter
the bs2 code above allows you to sent a 1 2 or 3 to the ps2 from pc serail connection
blinking a light 1 2 or 3 times
change com3 to whatever com the bs2 is on
change echo 3 >com3 to echo 2 >com3
or echo 1 >com3
with 8 bit data you can use 0-9 commands
if anyone knows how to receive serial input from the bs2 i could use it, the simpler the better
Comments
http://www.comp.lancs.ac.uk/~albrecht/sw/terminal/index.html