Shop OBEX P1 Docs P2 Docs Learn Events
basic stamp to usb to pc — Parallax Forums

basic stamp to usb to pc

walkin79walkin79 Posts: 29
edited 2011-01-18 11:48 in BASIC Stamp
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

  • Mike GreenMike Green Posts: 23,101
    edited 2011-01-17 15:44
    There's nothing special about communicating between a Basic Stamp and a PC via USB. The Stamp needs a serial port which can be supplied by a USB Board of Education or you can use a variety of USB to serial adapters. The PC side sees a serial port and ordinary I/O to a serial port as determined by the programming language and run-time library is all you need. As far as the content of the serial data, that's up to you. Have a look at Stamp Plot Pro which can be downloaded from Parallax's download page for the Stamps. This is used on the PC side for plotting data or reading or writing data for the Stamp among other things.

    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.
  • walkin79walkin79 Posts: 29
    edited 2011-01-18 11:48
    thanks for the info.... i actually found a solution online @ http://freeware.the-meiers.org/ this guy has written several interesting vb programs. Its free. the CoolTerm software works perfect to connect and control the basic stamp once you install it on your pc. make sure you have connected your basic stamp before you open the coolterm (so coolterm will recognise the com port your usb or serial is connected to)
    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
Sign In or Register to comment.