Sub Globals

FSvar=13
portflag = 0
strlabel0="COM 8: 9600,N,8,1"
strlabel1=" [OFF]"
strlabel2=" [ ON]"
strlabel3=" = "
strlabeltemp=""

End Sub

Sub App_Start

Form1.show
label1.Text = strlabel0 & strlabel1 & strlabel3
strlabeltemp  = strlabel0 & strlabel1 & strlabel3
serial.New2 (8,9600,"N",8,1)
textbox1.FontSize=FSvar
Sip=false

End Sub

Sub OpenPort_Click

If portflag = 0 Then
serial.PortOpen=true
portflag = 1
label1.Text = strlabel0 & strlabel2 & strlabel3
strlabeltemp=label1.Text
serial.enableoncomm=true
serial.Output ("*")
End If

End Sub

Sub ClosePort_Click

If portflag = 1 Then
TextBox1.Text=""
serial.Output ("^")
serial.enableoncomm=false
serial.PortOpen=false
portflag = 0
label1.Text = strlabel0 & strlabel1 & strlabel3
strlabeltemp=label1.Text
End If

End Sub

Sub serial_OnCom

TextBox1.Text=TextBox1.Text & serial.Inputstring

End Sub

Sub ClearWindow_Click

TextBox1.Text=""

End Sub

Sub ButtonG_Click

serial.Output ("G")
label1.Text = strlabeltemp & "G"

End Sub

Sub ButtonI_Click

serial.Output ("I")
label1.Text = strlabeltemp & "I"

End Sub
'This example program is written for the
'ATHENA microcontroller available from
'Kronos Robotics.
'This program will accept serial command 'characters sent from the HP IPAQ H2210
'PDA to the BlueSMiRF module.  The
'ATHENA microcontroller will receive the
'serial command characters from the
'BlueSMiRF module.  When the s2cpu
'flag is set equal to 1, the ATHENA will
'send the serial command characters on
'to the EzKEY module.  The EzKEY will
'process the serial command characters
'and send the results directly to the
'BlueSMiRF module which will send the
'results back to the PDA via the wireless
'Bluetooth connection.  The ATHENA
'microcontroller filters out the data
'strings that the BlueSMiRF sends out
'when the PDA Opens or Closes the
'Serial Comm Port connection.  The
'ATHENA makes sure that the data in
'these strings does not reach the EzKEY
'module, just in case any of the characters
'in the strings could be interpreted as
'command characters by the EzKey
'module.  By using the s2cpu flag, we can
'select when to send serial command
'characters to the EzKEY module.

'Dimension program variables.

dim a,s2cpu

'Initialize the s2cpu flag.
s2cpu=0

'Set Port Pin 0 as an Input.
input 0

'Set Port Pin 1 as an Output.
output 1

'Bring Port Pin 1 high.
high 1

'Set the Serial BAUD Rate.
setbaud SBAUD9600

'Continually look at Port Pin 0 to
'see if there is any Serial Data to
'be received.


loop1:
serin loop1,0,a


'If the special character * is received
'then set the s2cpu flag = 1 to enable
'the ATHENA to pass serial data
'characters to the EzKEY module.
'Jump back to label loop1 to look for
'the next serial byte to be received.


if a=42 then
s2cpu=1
goto loop1
endif


'If the special character ^ is received
'then set the s2cpu flag = 0 to disable
'the ATHENA so that serial data
'characters will not be passed on to the
'EzKEY module.  Jump back to program
'label loop1 to look for the next serial byte
'to be received.


if a=94 then
s2cpu=0
endif


'If the s2cpu flag = 1 and the received
'serial data byte is not one of the special
'characters, then pass this byte on to the
'EzKEY module to be processed.
'The EzKEY module will process the
'command and send the results
'directly to the BlueSMiRF module, which
'will send the results back to the PDA via
'the Bluetooth connection.


if s2cpu=1 then
serout 1,a
endif
goto loop1
HP IPAQ H2210 PDA,
BlueSMiRF Module and
ATHENA Microcontroller.
MultiLabs EzKEY Module
Interfaces to PS2 Keyboards.
Standard PS2 Keyboard.
Hardware Interface Schematic:     Connecting a BlueSMiRF
Module to the ATHENA Microcontroller and the EzKEY Module.
Program Code Listing for the EzKey Application which runs on the
Pocket PC written in BASIC using the BASIC4PPC Compiler Version 5.5.
Visit the following WebSites:
www.kronosrobotics.com
www.multilabs.net

www.basic4ppc.com

Read a PS2 Keyboard using a Bluetooth PDA.
www.sparkfun.com
For more information about
ATHENA microcontrollers visit:
For more information about
the PS2 EzKEY module visit:
For more information about
the BASIC compiler for the Pocket PC visit:
For more information about
the BlueSMiRF bluetooth module visit:
QUICK SPECS:
ATHENA microcontroller
Purpose:
The purpose of this website is to show how to
connect a Pocket PC PDA to an embedded
Bluetooth module.  An embedded microcontroller
or hardware module can be connected to the
Bluetooth module so that "Commands" and "Data"
can be transmitted and received via the wireless
Bluetooth  connection between the PDA and the
embedded hardware
.
Power Supply ......................  3.5V - 5.5V
Command Speed ................  15,000 per Sec
Clock Speed ........................  4 MHz
I/O Ports ..............................  Up to 15 In or Out
Program Memory ................. 256 Bytes
RAM  .................................... 64 Bytes
Timers .................................. 1
UART Baud Range ............... 9600 - 19200
Software Baud Range .........  1200 - 9600
PC Connection Speed .......... 9600
Operating Temperature .......  - 40 C to + 85 C
Max Load on an I/O port ....... 25 mA
Max Load on all I/O ports ..... 200 mA
Sleep Mode .......................... Less than 1 uA
Normal Operation No Load ... 800 uA
Program Writes ..................... 1,000,000           
For more information about
how to establish a Bluetooth
connection between a Pocket PC
PDA and a BlueSMiRF module visit:
Connect to a Pocket PC using Bluetooth.

Connect to a Pocket PC using Bluetooth.

Using Basic 4 PPC's ImageButton Control we can create a better looking interface for the software program running on the PPC.  The software code
is very similar, but the Form design is different.
The Buttons for the improved graphical interface version of the EzKey Software  Application were created using the button maker program called "Buttongadget 2".   Microsoft Paint was used to make minor adjustments to the JPEG button file images when necessary.
To improve the graphical user interface for the EzKey Software Application even more, Voice files were created for each button using the Text-To-Speech synthesizer program called "Second Speech Center".  When a button is pressed, a Voice message (.wav) file will be played to give an audible indication of the action being performed by the EzKey Software Application.
Here is the Program Code Listing for the improved GUI version of the
EzKey Software Application.   This version includes an audible Voice
Message for each Button on the Graphical User Interface.
Sub Globals
x=0
FSvar=13
ULfLAG=1
portflag = 0
strlabel0="COM 8: 9600,N,8,1"
strlabel1=" [OFF]"
strlabel2=" [ ON]"
strlabel3=" = "
strlabeltemp=""
End Sub

Sub App_Start
             Form1.show
              label1.Text = strlabel0 & strlabel1 & strlabel3
             strlabeltemp  = strlabel0 & strlabel1 & strlabel3
     
serial.New2 (8,9600,"N",8,1)
 
textbox1.FontSize=FSvar
Sip=false
End Sub

Sub serial_OnCom
TextBox1.Text=TextBox1.Text & serial.Inputstring
End Sub

Sub ImageButton1clearwin_Click
TextBox1.Text=""
Sound ("M_CW.wav")
End Sub

Sub ImageButton2initial_Click
   serial.Output ("I")
   label1.Text = strlabeltemp & "I"
Sound ("M_I.wav")
End Sub

Sub ImageButton3getdata_Click
   serial.Output ("G")
   label1.Text = strlabeltemp & "G"
Sound ("M_GD.wav")
End Sub

Sub ImageButton4openport_Click
Sound ("M_OP.wav")
If portflag = 0 Then
   serial.PortOpen=true
   portflag = 1
 label1.Text = strlabel0 & strlabel2 & strlabel3
  strlabeltemp=label1.Text
serial.enableoncomm=true
serial.Output ("*")
End If
End Sub

Sub ImageButton5closeport_Click
If portflag = 1 Then
   TextBox1.Text=""
   serial.Output ("^")
   serial.enableoncomm=false
   serial.PortOpen=false
   portflag = 0
 label1.Text = strlabel0 & strlabel1 & strlabel3
 strlabeltemp=label1.Text
End If
Sound ("M_CP.wav")
End Sub
The following is an explaination of each of the CONTROLS that
make up the EZKEY software application's GUI Design Form. 
A  BASIC4PPC:   LABEL  CONTROL
A  BASIC4PPC:   IMAGEBUTTON  CONTROL
A  BASIC4PPC:   IMAGEBUTTON  CONTROL
A  BASIC4PPC:   LABEL  CONTROL
A  BASIC4PPC:   TEXTBOX  CONTROL
A  BASIC4PPC:   IMAGEBUTTON  CONTROL
A  BASIC4PPC:   LABEL  CONTROL
A  BASIC4PPC:   IMAGEBUTTON  CONTROL
A  BASIC4PPC:   IMAGEBUTTON  CONTROL