Shop OBEX P1 Docs P2 Docs Learn Events
Serial problem...again Please help — Parallax Forums

Serial problem...again Please help

Drud0616Drud0616 Posts: 26
edited 2004-11-05 01:48 in BASIC Stamp
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


·

Comments

  • NewzedNewzed Posts: 2,503
    edited 2004-11-04 22:18
    It appears that when you say

    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
    ·
  • K de JongK de Jong Posts: 154
    edited 2004-11-05 01:29
    SERIN 15,16780,[noparse][[/noparse]WAIT(255),DrinkValue]
    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
  • Drud0616Drud0616 Posts: 26
    edited 2004-11-05 01:48
    Thanks K de Jong, I actually noticed that 10 minutes before I read your reply. That was exactly the reason why it wouldn't work.
Sign In or Register to comment.