tailieunhanh - Understanding and Using Visual Basic phần 3
Tham khảo tài liệu 'understanding and using visual basic phần 3', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Visual Basic - Communicating With The Microcontroller Micro-News Micro-Mailing-List Understanding and Using Visual Basic Part 5 By Jared Hoylman - Sending Data To A Microcontroller In the last article we went a little more in depth into Advanced String Parsing. These skills will be needed when receiving data from a microcontroller. All of the data received will be in a buffer and you will have to separate the data and use it accordingly. In this article we are going to learn how to send data to a microcontroller and make the microcontroller respond to the data. For simplicity we are just going to send data to turn certain pins on and off. So lets start off with designing a communications protocol. From VB we will send an ASCII 255 as a synch byte the pin number 0 to 15 and the on off state 0 or 1 . The microcontroller will wait for three 3 bytes of data. After these three bytes of data are received it will then either switch the pins to their High or Low state. The VB Part - To get started open Visual Basic. - Start a new Standard EXE. - Next go to the Project Components. menu - Check the MSComm Control. Click OK. - Next double-click on the yellow phone in the toolbar to add the MSComm control to your form. Your form should look like this. http 1 of 6 5 25 2004 8 48 24 PM Visual Basic - Communicating With The Microcontroller rrrrrrrrrrrrrrrrrrrrrrrrrrr Next we are going to add a Combo Box to our form and name it cboPinNumber. We are also going to add an Option Button to the form. Add the first one and name it optState. Select optState and press Ctrl-C to copy and then Ctrl-V to paste. You will get a propmt like the one below. Select Yes. Now you should notice that the first option button that you created has a name of optState 0 and the second one has a name of optState 1 . The number after the control name is the control array index. We will use this to our advantage later. Also add a Command button named cmdSend to the form. Go .
đang nạp các trang xem trước