Help with BS2p40 and development board
karabet
Posts: 17
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
·
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
Regards,
Jim
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Regards,
Karabet
·