Technology is progressing at break-neck speed, everyone of us has smart phones now-a-days, there are cool apps which let us stay in contact with our friends and family, get latest weather information or stay-updated with latest news but what's next? All of these are old-school techs by now, what is the next use of this amazing processing speed and cutting-edge communication method we carry around with us all times? If I say you can control the lights of your home, know that if heating is on? or if your mobile phone automatically shuts off your air conditioner? Ring bells? To close the software we must program the quit button as follow Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Application.If you are looking to connect a BLE (Bluetooth 4.0) module instead of Bluetooth 2.0 module, please see my new tutorial: How to control Arduino with HM-10 (CC2541) BLE module and a mobile app. Stop: Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click If (lstPorts.SelectedIndex -1) Then Right: Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click If (lstPorts.SelectedIndex -1) Then Left: Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click If (lstPorts.SelectedIndex -1) Then SendSerialData(, "w")īackward: Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click If (lstPorts.SelectedIndex -1) Then Now replace the code of each button as follow to control the movements Forward: Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click If (lstPorts.SelectedIndex -1) Then Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click If (lstPorts.SelectedIndex -1) Then Else "ERROR" to say something wrong in connection. This button click will recive a messege in consol as "OK" to confirm that bluetooth is connected with the device. MsgBox("Please choose a serial port", vbInformation, "Serial Port")Ĭlick the Button "Bluetooth Test" and replace the code. To initialize the button "Connect" replace the button code with Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If lstPorts.SelectedIndex -1 Then Imports System.Threading Public Class Form1ĭelegate Sub myMethodDelegate(ByVal As String)ĭim bD1 As New myMethodDelegate(AddressOf process)ĭim WithEvents SerialPort As New IO.Ports.SerialPort Private Sub Form1_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.DisposedĪnd below the code of Form1_Load Sub GetSerialPortNames() For Each sp As String In My.Įnd Sub Sub SendSerialData(ByVal Port As String, ByVal data As String)Įnd Sub Sub process(ByVal myString As String) buffer = buffer + myStringĭim words As String() = str.Split(New Char() )Įnd Sub Private Sub SerialPort_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort.DataReceivedĭim str As String = SerialPort.ReadExisting()Įnd Sub Private Sub SerialPort_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort.DataReceived Dim str As String = SerialPort.ReadExisting() Then add some additional code above the Form1_Load code to get your comm port and some function to work with your software Imports System.IO First Form load code.To do so double click in any where in the form and change the code to Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Now we program every components of the Form.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |