Shop OBEX P1 Docs P2 Docs Learn Events
Help with BS2p40 and development board — Parallax Forums

Help with BS2p40 and development board

karabetkarabet Posts: 17
edited 2010-04-11 20:56 in BASIC Stamp
Hi,
I’m using the professional development board, i want to turn on and off 2 LEDs that are connected to pin 2 and 3 from the BS2p40. But it’s not working, the same code i use it for BS2 with the board of education it will work. I really don’t know what is the reason can someone help me please the BASIC code and the VB code are:
' {$STAMP BS2p}
' {$PBASIC 2.5}
PinNumber· VAR·· Byte
PinState·· VAR·· Byte
·
Main:
·
' Use the programming port to receive
' data at 2400 baud
' Wait for the synch byte (255) and then
' get the PinNumber and PinState
SERIN 16,16780,[noparse][[/noparse]WAIT(255),PinNumber,PinState]
·
' If PinState=0 Then go to GoLow
' otherwise go to GoHigh
BRANCH PinState,[noparse][[/noparse]GoLow,GoHigh]
GOTO Main
·
·
' Set The pin low
GoLow:
LOW PinNumber
GOTO Main
·
·
' Set the pin high
GoHigh:
HIGH PinNumber
GOTO Main
·
========================================================================
And the VB code is:
·
Option Explicit
·
Private Sub cmdSend_Click()
Dim PinNumber As Long
Dim PinState As Long
·
'· Get Pin Number
PinNumber = cboPinNumber.ListIndex
·
'· Get Pin State
If optState(0).Value = True Then
··· PinState = 0
Else
··· PinState = 1
End If
·
' Send Out Data
MSComm1.Output = Chr$(255) & Chr$(PinNumber) & Chr$(PinState)
·
End Sub
·
Private Sub Form_Load()
Dim Pins As Long
·
'· Add the pin numbers 0 to 15 to cboPinNumber
For Pins = 0 To 15
··· cboPinNumber.AddItem CStr(Pins)
Next Pins
·
' Default to Pin 0 being selected
cboPinNumber.ListIndex = 0
·
' Default to optState(0) being selected
optState(0).Value = True
·
'· Use COM1
MSComm1.CommPort = 1
·
' 2400 baud, no parity, 8 data bits, 1 stop bit
MSComm1.Settings = "2400,N,8,1"
·
' Make sure DTR line is low to prevent Stamp reset
MSComm1.DTREnable = False
·
' Open the port
MSComm1.PortOpen = True
·
End Sub
·
·
Private Sub Form_Unload(Cancel As Integer)
MSComm1.PortOpen = False
End Sub

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Regards,

Karabet
·

Comments

  • hover1hover1 Posts: 1,929
    edited 2010-04-11 19:50
    The first thing you need to do is change your baudmode statment from 16780 to 17405. The numbers are different for the BS2p. (Check Help>SERIN in the IDE, there is a table there for different baud codes for the different BS2 chips).

    Regards,
    Jim
  • karabetkarabet Posts: 17
    edited 2010-04-11 20:56
    thanks Jim, it is working now

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Regards,

    Karabet
    ·
Sign In or Register to comment.