Shop OBEX P1 Docs P2 Docs Learn Events
Simple question with OBC's HC-06 Bluetooth LED Demo — Parallax Forums

Simple question with OBC's HC-06 Bluetooth LED Demo

vanmunchvanmunch Posts: 568
edited 2015-04-15 17:58 in Propeller 1
I've been working with one of those inexpensive HC-06 Bluetooth modules from eBay and I've been following an excellent "how to" that OBC wrote a few years ago here: http://www.gadgetgangster.com/news/56-jeffs-shop/534-bluetooth-howto.html

Everything is connected and I'm able to run the "Snake" and "LED" demo programs, but there seams to be a problem with the program receiving the majority of commands. I have to type the key command several times (~20- ~100) before the program responds and the LED turns on or off. The examples show the command only having to be typed in once for the program to respond.

Any suggestions on what I'm missing? Is there a way for the program to wait until "a:=serial.rxcheck" receives a value?

Thanks for your time,

Dave
CON

  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000

  bt_rxd = 20
  bt_txd = 21
  
  led = 19  'led placed between 18/19 - Insert negative leg into p18

OBJ

serial : "FullDuplexSerial"

PUB LedOn | a                    

  serial.start(bt_txd,bt_rxd,0000,9600)                    
                   
    dira[led] := 1
    dira[led-1] := 1
    outa[led-1] := 0
  
    repeat                       
        a:=serial.rxcheck
        if a == 97 
           outa[led] := 1
           serial.str(string("LED ON",13))
        if a == 98
           outa[led] := 0
           serial.str(string("LED OFF",13))  

Comments

  • vanmunchvanmunch Posts: 568
    edited 2015-04-15 17:58
    I figured it out! :)

    I was reading through the instructions a few more times and realized that I had failed to set the Baud Rate in the serial Terminal to match the Bluetooth module, 9600. The mismatch allowed data to come in, but mostly garbled the data going out. Hopefully this helps someone else someday. Again, a huge shout out to OBC for this excellent demo. Thanks!

    Dave
Sign In or Register to comment.