PDA

View Full Version : Easy blue tooth module 30085 help needed !



NehminD
01-28-2010, 12:28 AM
Hi Guys,

I am a student currently having a project which involve using basic stamp and 2 easy blue tooth module.

The product number for the blue tooth module is 30085.
With the help of the guiding code I am able to finish certain part of it, but I face problem.

The problem is that I have a circuit that will produce binary output and I am not sure what code should I need to change in order for the blue tooth to able to send the binary output from the transmit side to the receiving side.

Can any kind soul out there help me please>??

Mike Green
01-28-2010, 01:21 AM
The Bluetooth module simply provides a wireless equivalent of a cable connecting one Bluetooth module to another. Once the Bluetooth connection is set up (as shown in the sample programs), you can send any bytes you want from one to the other. The easiest way to send binary data is by using the characters "0" and "1" with a carriage return character ($0D) separating the values. You would use a SEROUT statement on one end and a SERIN statement on the other end to receive it. If <pin> is the I/O pin used, <Baud> is the Baud constant as shown in the Stamp Manual, and <value> is the name of the variable you're using, you'd use

SEROUT <pin>,<Baud>,[BIN <value> , $0D]

to transmit the value and

SERIN <pin>,<Baud>,[BIN <value>]

to receive the value at the other end. The SERIN will use the $0D to mark the end of the value and will otherwise ignore it.

Read the BASIC Stamp Syntax and Reference Manual chapters on the SERIN and SEROUT statements and the appendix on the I/O formatters like BIN for details.

NehminD
01-28-2010, 09:38 AM
Thanks Mike for the help.
I will try out the program first

NehminD
01-28-2010, 11:14 PM
Dear Mike and all kind soul.

Hi, I have try to do some coding and hope you all will take some time to look at it.

Below is my code for sending :

' {$STAMP BS2}
' {$PBASIC 2.5}
'
'File: EasySEND.bs2
'
'Purpose: Load on the transmitting unit in the AppNote Easy Bluetooth to Easy Bluetooth Communcation.
'· The example connects to the remote Bluetooth module via serial connection. An address is given to the
'· remote module that the transmitting unit uses to establish connection. 5 seconds after the connection
'· is attempted then a counter variable is sent and incremented by 1 in a repeat loop and then will DEBUG
'· the counter value.
'
'Author: Parallax Technical Support

' ' '' ' '' ' ' Declarations ' ' '' ' '' ' '' ' ''
RX······· PIN 2
TX······· PIN 0
LIGHT1··· PIN 1
Light2··· PIN 3
Light3··· PIN 5
counter·· VAR Bit
'Place the values for each part of the address in the constants below; whereas the first part of the address will be placed in
'addy1 and the second in addy2; for example the address A1:B2:C3:D4:E5:F6 would be edited to look like the following:
'··· addy1·· CON· $A1···· <--- A1 from A1:B2:C3:D4:E5:F6 goes here
'··· addy2·· CON· $B2···· <--- B2 from A1:B2:C3:D4:E5:F6 goes here
'··· addy3·· CON· $C3···· <--- C3 from A1:B2:C3:D4:E5:F6 goes here
'··· addy4·· CON· $D4···· <--- D4 from A1:B2:C3:D4:E5:F6 goes here
'··· addy5·· CON· $E5···· <--- E5 from A1:B2:C3:D4:E5:F6 goes here
'··· addy6·· CON· $F6···· <--- F6 from A1:B2:C3:D4:E5:F6 goes here
' Place the address for the receiving Easy Bluetooth modules below
'( the address for the Easy Bluetooth module used in the example is 00:17:a0:01:56:b1 )
···· addy1·· CON· $00
···· addy2·· CON· $17
···· addy3·· CON· $a0
···· addy4·· CON· $01
···· addy5·· CON· $56
···· addy6·· CON· $b1
#SELECT $STAMP
· #CASE BS2, BS2E, BS2PE
··· Baud······ CON···· 84
· #CASE BS2SX, BS2P
··· Baud······ CON···· 240
· #CASE BS2PX
··· Baud······ CON···· 396
#ENDSELECT
' ' '' ' '' ' ' Program ' ' '' ' '' ' '' ' ''
Program_Start:
· DEBUG CLS
· PAUSE 3000
· DEBUG CR,"Establishing SPP connection..."
· SEROUT TX, Baud, [$02,$52,$0A,$08,$00,$64,$01,addy6,addy5,addy4,addy 3,addy2,addy1,$01,$03]
· PAUSE 5000
· DEBUG CR,"Entering Transparent mode...",CR
· 'Entering Transparent mode
· SEROUT TX, Baud, [$02,$52,$11,$01,$00,$64,$01,$03]
· PAUSE 3000
· 'Transmitting counter variable to remote Bluetooth device and to the DEBUG terminal
IF Light1 = 1 THEN
SEROUT 1,Baud,[BIN 1,$0D]
ENDIF
IF Light1 = 0 THEN
SEROUT 1,Baud,[BIN 0,$0D]
ENDIF
IF Light2 = 1 THEN
SEROUT 2,Baud,[BIN 1,$0D]
ENDIF
IF Light2 = 0 THEN
SEROUT 2,Baud,[BIN 0,$0D]
ENDIF
IF Light3 = 1 THEN
SEROUT 3,Baud,[BIN 1,$0D]
ENDIF
IF Light3 = 0 THEN
SEROUT 3,Baud,[BIN 0,$0D]
ENDIF


This will be my code for receive :

' {$STAMP BS2}
' {$PBASIC 2.5}
'
'File: EasyR.bs2
'
'Purpose: Load on the receiving unit in the AppNote Easy Bluetooth to Easy Bluetooth Communcation.
'· The example waits for a value counter to be sent via Bluetooth connection and then will display
'· the value on the DEBUG screen
'
'Author: Parallax Technical Support
' ' '' ' '' ' ' Declarations ' ' '' ' '' ' '' ' ''
RX······· PIN 2
TX······· PIN 0
Temp····· VAR Byte
#SELECT $STAMP
· #CASE BS2, BS2E, BS2PE
··· Baud······ CON···· 84
· #CASE BS2SX, BS2P
··· Baud······ CON···· 240
· #CASE BS2PX
··· Baud······ CON···· 396
#ENDSELECT
' ' '' ' '' ' ' Program ' ' '' ' '' ' '' ' ''
DO
· GOSUB GETVAL
· GOSUB DISPLAY
· PAUSE 5
LOOP
' ' '' ' '' ' ' Subroutines ' ' '' ' '' ' '' '
GETVAL:
· SERIN RX, Baud, [Temp]······························· ' Waits for a BYTE and puts that value in Temp
RETURN
DISPLAY:
· DEBUG HOME, "Byte = ",DEC Temp,CLREOL,CR· ' Displays the decimal value for Temp
RETURN



AND I am really NEW in this so ANY form of help is wanted
More infomation can be seen in the first post PLS HELP
·

Mike Green
01-29-2010, 12:21 AM
Please read the description (and examples of the use) of the SEROUT statement. The "<pin>" number or name is the I/O pin to be used for transmitting the data. I don't understand why you put "1", "2", and "3" in the SEROUT statements. The "<pin>" value needs to be "TX" because you're sending data to the Bluetooth module.

In your original description, you only mentioned the need to send a binary (on / off) value, yet you posted some code that has 3 binary values. What do you want to do?

NehminD
01-30-2010, 11:34 PM
Replying to Mike

Yes I am trying to send a binary from 1 bluetooth module to the other.
I think I have trouble with the code.
For example:
IF Light1 = 1 THEN
SEROUT 1,Baud,[BIN 1,$0D]
ENDIF

I will send Binary 1 to output pin 1 if Light 1 = 1 .

which will explain there is total of 3 light that I will be controlling .
Am i not not really sure which part of the code is wrong, I have least understanding of the basic stamp code.

And for more infromation basically our project will go something like this :

When a speaker say Light 1 on , the wireless will process a binary to a circut and transmit a binary output to·the transmit side and then send to the receiver which will light the light of each different light and we can only set a binary at a time, which means that we can only control 1 Light at a time

Post Edited (NehminD) : 1/30/2010 3:43:13 PM GMT

Mike Green
01-30-2010, 11:44 PM
How about just sending the 3 values like this:

SEROUT TX,Baud,["!",BIN Light1,",",BIN Light2,",",BIN Light3,$0D]

On the receive end, you'd have

SERIN RX,Baud,[WAIT("!"),BIN temp1,BIN temp2,BIN temp3]

The "!" just marks the beginning of the data and the "," separates the numbers.
The BIN will use the "," or the $0D as a delimiter to mark the end of the number and otherwise ignore it.

NehminD
01-31-2010, 01:57 AM
I can't really send all 3 at a go as my project is using speech to control the light.

So can the coding be like

SEROUT TX(this should be the input pin right?) , Baud,["!"(which is my circuit output I suppose ?), BIN light1,$0D]

receive will be

SERIN RX,Baud,[WAIT("!"),BIN temp1]


And hope that you can explain ! and , in more layman term if can explain relate back to my project will be better.

And thank a lot for your effort by doing so much for a stranger like me