Control a Basic Stamp module using Basic4PPC.

pdablue

Active Member
Licensed User
Longtime User
Hi,

This program example allows you to control Output Pins P0 thru P7
on a Basic Stamp using a BlueTooth module and a HP210 PDA running
this Basic4PPC program.

When you press a button the PDA will send a one byte character command
to the Basic Stamp using a wireless BlueTooth connection. The program
running on the Basic Stamp will analyze the single byte character and
take the appropriate action.

This program example allows you to set each Basic Stamp Port Pin
(P0 thru P7) High or Low individually.

You can also set all Port Pins (P0 - P7) High at one time.
You can also set all Port Pins (P0 - P7) Low at one time.

You can Open and Close the BlueTooth Communications Port.

You can clear the TX and RX windows.

When you press a button the character that is transmitted is displayed in
the TX window. If your hardware sent a character back to the PDA it
would be displayed in the RX window.

Port pin P15 on the Basic Stamp is used to receive serial data from the
wireless BlueTooth connection with the PDA.

The RS232 module is plugged into the BlueTooth module to convert
the received data into TTL voltage levels before it enters Port pin
P15 on the Basic Stamp.

Here is a listing of the program code that runs on the Basic Stamp:

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

serdata VAR Byte
Baud CON 240

INPUT 15

OUTPUT 0
OUTPUT 1
OUTPUT 2
OUTPUT 3
OUTPUT 4
OUTPUT 5
OUTPUT 6
OUTPUT 7

LOW 0
LOW 1
LOW 2
LOW 3
LOW 4
LOW 5
LOW 6
LOW 7

Main:

DO
SERIN 15,Baud,[serdata]

'Character A was received. Set P0 High.
IF serdata=65 THEN
HIGH 0
ENDIF

'Character B was received. Set P0 Low.
IF serdata=66 THEN
LOW 0
ENDIF

'Character C was received. Set P1 High.
IF serdata=67 THEN
HIGH 1
ENDIF

'Character D was received. Set P1 Low.
IF serdata=68 THEN
LOW 1
ENDIF

'Character E was received. Set P2 High.
IF serdata=69 THEN
HIGH 2
ENDIF

'Character F was received. Set P2 Low.
IF serdata=70 THEN
LOW 2
ENDIF

'Character G was received. Set P3 High.
IF serdata=71 THEN
HIGH 3
ENDIF

'Character H was received. Set P3 Low.
IF serdata=72 THEN
LOW 3
ENDIF

'Character I was received. Set P4 High.
IF serdata=73 THEN
HIGH 4
ENDIF

'Character J was received. Set P4 Low.
IF serdata=74 THEN
LOW 4
ENDIF

'Character K was received. Set P5 High.
IF serdata=75 THEN
HIGH 5
ENDIF

'Character L was received. Set P5 Low.
IF serdata=76 THEN
LOW 5
ENDIF

'Character M was received. Set P6 High.
IF serdata=77 THEN
HIGH 6
ENDIF

'Character N was received. Set P6 Low.
IF serdata=78 THEN
LOW 6
ENDIF

'Character O was received. Set P7 High.
IF serdata=79 THEN
HIGH 7
ENDIF

'Character P was received. Set P7 Low.
IF serdata=80 THEN
LOW 7
ENDIF

'Character Q was received. Set P0,P1,P2,P3,P4,P5,P6,P7 High.
IF serdata=81 THEN
HIGH 0
HIGH 1
HIGH 2
HIGH 3
HIGH 4
HIGH 5
HIGH 6
HIGH 7
ENDIF

'Character R was received. Set P0,P1,P2,P3,P4,P5,P6,P7 Low.
IF serdata=82 THEN
LOW 0
LOW 1
LOW 2
LOW 3
LOW 4
LOW 5
LOW 6
LOW 7
ENDIF

LOOP
END


When you run the Basic4PPC program on the PDA you will need to Open the Bluetooth serial port connection first.
If you do not then you will get error messages when you press a button and the program tries to send a character
out the serial port. If the port is closed when you push a button then you will get an error message.

This Basic4ppc program was written to run on a HP210 PDA.

The file MicroInstall.zip is the zipped up .CAB installation file for the PDA.
The file MICRO.sbp is the Basic4PPc source code file.
The file serialmicro.txt is the code for the Basic Stamp.
 

Attachments

  • bluefly2.jpg
    bluefly2.jpg
    31.7 KB · Views: 265
  • stamppic2.jpg
    stamppic2.jpg
    62.3 KB · Views: 246
  • MICRO.sbp
    10.9 KB · Views: 343
  • micropic2.jpg
    micropic2.jpg
    66.5 KB · Views: 255
  • serialmicro.txt
    1.8 KB · Views: 279
  • RS232.jpg
    RS232.jpg
    75.7 KB · Views: 253
  • hp210pic2.jpg
    hp210pic2.jpg
    41.6 KB · Views: 253
  • MicroInstall.zip
    77.2 KB · Views: 306
Last edited:

Xeniczone

Member
Licensed User
This is exactly what I needed Microcontroller to PocketPC communication over bluetooth.

Do you have links or names for the bluetooth module or the RS232 adapter?
 

pdablue

Active Member
Licensed User
Longtime User
Bluetooth Modules and RS232 adapters.

Hi,

I purchased the Firefly-BP (Battery Powered) module from a company
called Grid Connect. You can Google them to find their website on the
Internet.

I purchased an RS232 module from Kronos Robotics (www.kronosrobotics.com).
It is called the "Easy RS232 Interface Kit". The one I have I purchased several
years ago and the new ones that Kronos currently sells look different due to a
different Printed Circuit Board layout. You can find them listed in the
"Easy Modules" section of their website.

SparkFun Electronics sells some RS232 modules and they can be
found at many of the Hobby Robotics\Electronics websites on
the Internet.
 
Last edited:
Top