Control a Basic Stamp with B4PPC and a LG Fathom Windows Mobile Phone.

pdablue

Active Member
Licensed User
Longtime User
Hi,

This program example will allow you to control Output port pins on
a Basic Stamp using an LG Fathom Windows Mobile Phone and a wireless
BlueTooth module.

You can control 12 of the Basic Stamps Output pins (P0 - P11).
Port pin P15 is used to receive data from the Bluetooth module.
Port pins P12, P13 and P14 are not used and can be used for
other things.

You can set Port Pins (P0 - P11) High or Low individually.
You can set all Port Pins (P0 - P11) High at one time.
You can set all Port Pins (P0 - P11) Low at one time.

You can Open and Close the Bluetooth Serial Communications
port.

You can Clear the TX and RX windows. When a button is pressed,
the single byte character command that is transmitted is displayed
in the TX window. If the external hardware sent data back to the
PDA it would be displayed in the RX window.

The LG Fathom runs the B4PPC program which sends data commands
to the wireless bluetooth adapter which is plugged into an RS232
converter board that is connected to Port Pin 15 of the Basic Stamp.
When a single byte character command is received by the Basic Stamp
it will analyze it and perform the specified action.

Here is a listing of the Basic Stamp program code:

' {$STAMP BS2p}
' {$PBASIC 2.5}

serdata VAR Byte
valdata VAR Byte
Baud CON 240

INPUT 15

OUTPUT 0
OUTPUT 1
OUTPUT 2
OUTPUT 3
OUTPUT 4
OUTPUT 5
OUTPUT 6
OUTPUT 7
OUTPUT 8
OUTPUT 9
OUTPUT 10
OUTPUT 11

LOW 0
LOW 1
LOW 2
LOW 3
LOW 4
LOW 5
LOW 6
LOW 7
LOW 8
LOW 9
LOW 10
LOW 11

Main:

DO
SERIN 15,Baud,[serdata]

LOOKDOWN serdata,[65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90],valdata
BRANCH valdata,[c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17,c18,c19,c20,c21,c22,c23,c24,c25,c26]
GOTO jumpend

c1:
'Character A was received. Set P0 High.
HIGH 0
GOTO jumpend

c2:
'Character B was received. Set P0 Low.
LOW 0
GOTO jumpend

c3:
'Character C was received. Set P1 High.
HIGH 1
GOTO jumpend

c4:
'Character D was received. Set P1 Low.
LOW 1
GOTO jumpend

c5:
'Character E was received. Set P2 High.
HIGH 2
GOTO jumpend

c6:
'Character F was received. Set P2 Low.
LOW 2
GOTO jumpend

c7:
'Character G was received. Set P3 High.
HIGH 3
GOTO jumpend

c8:
'Character H was received. Set P3 Low.
LOW 3
GOTO jumpend

c9:
'Character I was received. Set P4 High.
HIGH 4
GOTO jumpend

c10:
'Character J was received. Set P4 Low.
LOW 4
GOTO jumpend

c11:
'Character K was received. Set P5 High.
HIGH 5
GOTO jumpend

c12:
'Character L was received. Set P5 Low.
LOW 5
GOTO jumpend

c13:
'Character M was received. Set P6 High.
HIGH 6
GOTO jumpend

c14:
'Character N was received. Set P6 Low.
LOW 6
GOTO jumpend

c15:
'Character O was received. Set P7 High.
HIGH 7
GOTO jumpend

c16:
'Character P was received. Set P7 Low.
LOW 7
GOTO jumpend

c17:
'Character Q was received. Set P8 High.
HIGH 8
GOTO jumpend

c18:
'Character R was received. Set P8 Low.
LOW 8
GOTO jumpend

c19:
'Character S was received. Set P9 High.
HIGH 9
GOTO jumpend

c20:
'Character T was received. Set P9 Low.
LOW 9
GOTO jumpend

c21:
'Character U was received. Set P10 High.
HIGH 10
GOTO jumpend

c22:
'Character V was received. Set P10 Low.
LOW 10
GOTO jumpend

c23:
'Character W was received. Set P11 High.
HIGH 11
GOTO jumpend

c24:
'Character X was received. Set P11 Low.
LOW 11
GOTO jumpend

c25:
'Character Y was received. Set P0,P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11 High.
HIGH 0
HIGH 1
HIGH 2
HIGH 3
HIGH 4
HIGH 5
HIGH 6
HIGH 7
HIGH 8
HIGH 9
HIGH 10
HIGH 11
GOTO jumpend

c26:
'Character Z was received. Set P0,P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11 Low.
LOW 0
LOW 1
LOW 2
LOW 3
LOW 4
LOW 5
LOW 6
LOW 7
LOW 8
LOW 9
LOW 10
LOW 11

jumpend:
LOOP ' repeat forever
END
 

Attachments

  • microlg1.jpg
    microlg1.jpg
    46.8 KB · Views: 278
  • styluslg1.jpg
    styluslg1.jpg
    54 KB · Views: 270
  • Capture2.jpg
    Capture2.jpg
    69.7 KB · Views: 296
  • micro12r.jpg
    micro12r.jpg
    75.7 KB · Views: 269
  • microcom12.sbp
    14.9 KB · Views: 283
  • serial12micro.txt
    2.6 KB · Views: 269
  • stamppic2.jpg
    stamppic2.jpg
    62.3 KB · Views: 293
Last edited:
Hi,

i am doing a similar project, i am new to this and i was hoping to learn from you.
I have a few questions,

1) I am using Parallax Easy Bluetooth module and Board of education
2) Windows mobile SDK professional 6.0 as an emulator

i have tried using the code you have provided and when i used the emulator, it could detect the easy bluetooth, but it does not respond when i tried to control it with the emulator. Can you guide me on this ?

I modified part of the code as per below as i am using the easy bluetooth instead:
Instead of LOOKDOWN and BRANCH, i used IF and ELSEIF as my program is relatively short, using only pin 1 for testing lighting up and LED.

RX PIN 2 ' RX of the Easy Bluetooth
TX PIN 0 ' TX of the Easy Bluetooth

Baud CON 84 ' Baud set at 9600

'
SERIN RX, Baud, [Sig_IN] ' receive input from user

IF (Sig_IN = "0") THEN 'Turn on LED

OUT1=0

ELSEIF (Sig_IN = "1") THEN 'Turn off LED

OUT1=1
 
Last edited:

pdablue

Active Member
Licensed User
Longtime User
Windows Mobile Emulator Question.

Hi,

I have not used the Windows Mobile Emulator, I do all of my testing either
on a PDA or a Windows Mobile Phone.

I do not know how the Emulator actually handles emulation of the Com Port.

I would suggest that you try an actual PDA or a Windows Mobile Phone
to test your code.

If you want to use the Emulator you may have to modify the Com Port
settings until you find a setting that actually sends and receives data
with the hardware setup that you are using.
 

SaShiMe

New Member
Hi, i have a similar problem as well. I created all my buttons with the desktop IDE and complied it into .exe , from there i followed the instructions under the tutorial by loading it with a mobile emulator so it works like a real phone. how ever i am quite stuck(sorry i am a noob, even after reading so many tutorials). I realised that i do not know what are the parts that are needed to connect my phone with the easy bluetooth. i noticed that in ur phone app, we can select com port and stuff(my TX RX and default written into basic stamp), how can i do that too?

i.e. i created my buttons, how i can connect basic stamp and basic4ppc so that when i press the button, a signal is sent over to the basic stamp? sorry i do not know much about bluetooths.
 

pdablue

Active Member
Licensed User
Longtime User
(.exe) app on a Desktop communicating with a Basic Stamp.

Hi,

If you have written your application to run as a stand alone (.exe)
program on a desktop computer, you can connect the desktop
computer to a Basic Stamp using a RS232 serial port cable.

You will need to write your application so that it uses the SerialEx.Dll
to open and close the Desktop computer serial port. You will have to
experiment with your Desktop computer to find out which com port is
available for your application to use: (com1, com2, com3, ... etc.)

You will need an RS232 Interface IC to connect the serial port cable
from the desktop to the Basic Stamp's port pin(s). You can connect
up to just one of the Basic Stamp's port pins if you just want to
receive characters from the Desktop computer.

If you write your application to run as a stand alone (.exe) file, you
will not need to use the emulator.


(Desktop Computer) <------ RS232 Serial Cable ------ RS232 Interface IC -----> (Basic Stamp)

For more Bluetooth info you can visit the following websites:

http://www.micropda.50webs.com/index.html

http://www.stormpages.com/microbox/index.html
 
Last edited:
Top