Serial problem...again Please help
Drud0616
Posts: 26
I wrote a program in VB in order to allow a user to choose a drink from a listbox.· Once the user chooses a drink the program should send a value (0-5) through the serial port and into my BS2.· I rigged 6 LEDs on a board in order to see if the signal is outputted.· Problem is the lights do not light up.· Any help would·be greatly appreciated.·
My VB code looks like this...
Private Sub Form_Load()
'Use COM1
MSComm1.CommPort = 1
'9600 baud, no parity, 8 data bits, 1 stop bit
MSComm1.Settings = "9600,N,8,1"
'Open the port
MSComm1.PortOpen = True
'Add Drinks to the list
lstMdrinks.AddItem "Vodka Tonic"
lstMdrinks.AddItem "Vodka ScrewDriver"
lstMdrinks.AddItem "Vodka Coke"
lstMdrinks.AddItem "Rum and Coke"
lstMdrinks.AddItem "Tequila ScrewDriver"
lstMdrinks.AddItem "Rum and Tonic"
End Sub
Private Sub cmdAccept_Click()
'intDrinkValue will have a value 0-5
intDrinkValue = lstMdrinks.ListIndex
MSComm1.Output = Chr$(255) & Chr$(intDrinkValue)
End Sub
The part in written in PBasic looks like this...
DrinkValue· VAR·· Byte
Main:
' Use the programming port to receive
' data at 9600 baud to pin15
' Wait for the synch byte (255) and then
' get the DrinkValue
SERIN 15,16780,[noparse][[/noparse]WAIT(255),DrinkValue]
HIGH DrinkValue
END
·
My VB code looks like this...
Private Sub Form_Load()
'Use COM1
MSComm1.CommPort = 1
'9600 baud, no parity, 8 data bits, 1 stop bit
MSComm1.Settings = "9600,N,8,1"
'Open the port
MSComm1.PortOpen = True
'Add Drinks to the list
lstMdrinks.AddItem "Vodka Tonic"
lstMdrinks.AddItem "Vodka ScrewDriver"
lstMdrinks.AddItem "Vodka Coke"
lstMdrinks.AddItem "Rum and Coke"
lstMdrinks.AddItem "Tequila ScrewDriver"
lstMdrinks.AddItem "Rum and Tonic"
End Sub
Private Sub cmdAccept_Click()
'intDrinkValue will have a value 0-5
intDrinkValue = lstMdrinks.ListIndex
MSComm1.Output = Chr$(255) & Chr$(intDrinkValue)
End Sub
The part in written in PBasic looks like this...
DrinkValue· VAR·· Byte
Main:
' Use the programming port to receive
' data at 9600 baud to pin15
' Wait for the synch byte (255) and then
' get the DrinkValue
SERIN 15,16780,[noparse][[/noparse]WAIT(255),DrinkValue]
HIGH DrinkValue
END
·
Comments
high drink value
you want an LED to come on.· The LEDs have to be connected to a Stamp pin.· Then you can say
if drinkvalue = 1 then
high 0·················· 'or whatever pin LED1 is connected to
endif
if drinkvalue = 2 then
high 1
endif
and so on.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
New Combo LCD Backpack
http://hometown.aol.com/newzed/index.html
·
HIGH DrinkValue
You use pin 15 here. If you take the signal from the progrzamming port as you said you will have to use pin 16 !!
Klaus