Shop OBEX P1 Docs P2 Docs Learn Events
Spin for easybluethooth? — Parallax Forums

Spin for easybluethooth?

Kris CardoenKris Cardoen Posts: 46
edited 2012-04-04 16:29 in Accessories
Hy

I want to use my easy bluetooth module (from my basic stamp) on to my propeller board of education.
I have connected the power, and from the led I can confirm it receives signals.

I have connected RX to pin 0 en TX to pin1 op de propeller board of education.


How do I make it run? I tried to find info about this topic, but the info is very confusing.
There objects but they where written for USB and I can't seem to find my way. There are also a lot of different objects ....



I just want a very simple example.
Connect to the BT device (rx= pin1 Tx=pin2 baudrate=9600)

Thx for feedback


Regards,
Kris

Comments

  • Martin_HMartin_H Posts: 4,051
    edited 2012-04-03 11:27
    Easy Bluetooth looks just like a 9600 baud serial device. I use the ParallaxSerialTerminal with code roughly like the following:
      pst : "Parallax Serial Terminal.spin" 
    
    PUB Main 
      ' throw in a waitcnt here to give you a chance to open the terminal on the PC side.
      pst.Start(9600)
      pst.str(string(“Hello World“))       
    
  • Kris CardoenKris Cardoen Posts: 46
    edited 2012-04-03 13:14
    Hi,

    But if I don't specify my Rx/Tx port of the bluetooth device connected, it will just try to use the standard terminal?

    Regards,
    Kris
  • Martin_HMartin_H Posts: 4,051
    edited 2012-04-03 13:47
    OK, if you open the file Parallax Serial Terminal.spin you'll see it has two start methods. One Start only takes a single argument (baud rate) and the other StartsRxTx takes four arguments (rxpin, txpin, mode, baudrate) . The argument signature for the second method looks like this:
    PUB StartRxTx(rxpin, txpin, mode, baudrate) : okay
    {{Start serial communication with designated pins, mode, and baud.
      Parameters:
        rxpin    - input pin; receives signals from external device's TX pin.
        txpin    - output pin; sends signals to  external device's RX pin.
        mode     - signaling mode (4-bit pattern).
                   bit 0 - inverts rx.
                   bit 1 - inverts tx.
                   bit 2 - open drain/source tx.
                   bit 3 - ignore tx echo on rx.
        baudrate - bits per second.
      Returns    : True (non-zero) if cog started, or False (0) if no cog is available.}}
    

    The Start method called the StartRxTx with these arguments (31, 30, 0, baudrate) so it defaults to pins 30 (tx pin) and 31 (rxpin). So you would call StartRxTx with the pins you have the Bluetooth module connected to.
  • Kris CardoenKris Cardoen Posts: 46
    edited 2012-04-04 12:33
    Hi,

    I have tested the following code? but it did not work. Until I switched Rx and Tx.
    I dont understand completely why but it works fine now!!!!!

    Thank you very much for your help!!!

    Regards,

    OBJ
    system : "Propeller Board of Education"
    pst : "Parallax Serial Terminal Plus"
    time : "Timing"
    pin : "Input Output Pins"

    VAR
    long a
    PUB Go
    system.Clock(80_000_000)

    pst.StartRxTx(0, 1, 0,9600)

    repeat
    pin.High(2)
    time.Pause(100)
    pin.Low(2)
    time.Pause(100)
    pst.Str(String("test terminal "))
  • Martin_HMartin_H Posts: 4,051
    edited 2012-04-04 16:29
    Great, glad to hear it. As to your TX and Rx issue, that gets me sometimes too.
Sign In or Register to comment.