Shop OBEX P1 Docs P2 Docs Learn Events
Read character out of a serial port — Parallax Forums

Read character out of a serial port

Do anybody know any code for the Basic Stamp2 to read characters out of a serial port of a USB host I have? The USB host its connected to a keyboard and when a key is pressed sends characters out (TX) to the stamp2 (RX). 9600 baud.
I need a Serin code to start with.
Please help!
Here is the link of the USB host with an Arduino example:
http://www.hobbytronics.co.uk/usb-host/usb-host-keyboard

Comments

  • From the specs, this device is a standard source of serial data at 9600 Baud at 5V so it should work with

    SERIN <pin>,84,[c]

    where c is defined as a byte or word variable. Read the chapter on the SERIN statement in the Basic Stamp Syntax and Reference Manual for details.
  • Mike Green wrote: »
    From the specs, this device is a standard source of serial data at 9600 Baud at 5V so it should work with

    SERIN <pin>,84,[c]

    where c is defined as a byte or word variable. Read the chapter on the SERIN statement in the Basic Stamp Syntax and Reference Manual for details.

    Thanks Mike. I little confused about baud. It should be inverted? (Im not sure what that is). Is this OK to use for the baud begining code?:
    #SELECT $STAMP
    #CASE BS2
    T9600 CON 84
    #END SELECT

    THANKS YOUR YOUR HELP.
    Luis

  • There are converter chips for RS232<->TTL that invert the signals 1<->0 and the inverted mode is intended to compensate for this. These days, don't bother with it unless you know you need it. Most serial I/O is "TTL" true mode since all the USB to serial adapter chips use it.

    The #SELECT statement you showed is used to adjust the Baud constants for different Stamp models. If you're only going to be using one Stamp model, you can leave that out. You could either use

    T9600 CON 84

    or

    Baud CON 84

    and use that name in your SERIN and SEROUT statements
Sign In or Register to comment.