basic stamp to usb to pc
walkin79
Posts: 29
I am trying to find a c++ code to be able to communicate with the basic stamp through usb (control the functions of the stamp, lights, sound, motors ect....) i have a visual basic program but i need an executeable for the desk top. I was hopeing some one might have some source code for this, if your interested in the visual basic i can send it it works, i didnt write it.
Comments
The details for use of a serial port in C++ depend on the particular implementation. Look in your manuals and on-line help for examples.
you have to go to options on coolterm and change to the com port your basic is on; example (com1). here is a sample of the basic code i use to create a beep sound. when you press 1 or 2 there is a beep, any other value will give an error beep.
this is set at 9600 baude rate you shouldnt need to change anything except the pin your speaker is on and the com port on coolterm .
This is a simple code but you can modify it for servos lights ect...
this code is ready to go just copy and paste in your editor..... good luck
' {$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 4
'
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 ELSE
GOSUB Task3
RETURN
ENDSELECT
Task1:
FOR Counter = 1 TO 3
FREQOUT BEEPER, 100, 3500
PAUSE 50
NEXT
RETURN
Task2:
FOR Counter = 1 TO 3
FREQOUT BEEPER, 100, 3750
PAUSE 50
NEXT
RETURN
Task3:
FREQOUT BEEPER, 500, 3500
PAUSE 50
RETURN