I want to start programming in visual basic using the lib firmata, already installed the firmata to vb but I can not find any tutorial, can someone help me get started
try this link: Arduino <> Firmata <> Visual Basic .NET
I am a python programmer so if you decide you want to use python instead let me know
hello! Thanks, I know this site but I can not meeting any code example was when I downloaded the lib firmata
I need sites with example code with vb
visual studio express 2012 and making a Windows Form Application.
installing firmata.dll, DigitalPinControl.dll, AnalogPinControl.dll,,,if you havent.
First start new project windows forms application (visual basic), now your on your form1.vb (design) left click form and goto toolbox (Ctrl+w,x) NOT tools at top, you should get a menu on the left side.
at the bottom in general if firmata isnt there right click and choose items... in the window that comes up, in .net framework components click browse and go to the folder that has firmata.dll etc..in and load, ok its now in general drag it to your window, you should have an icon under the form1 window if you click on that icon then look at the property on the left side you can change opions.
Now on the right hand side in the solution window there is a black spaner double click on that, that will give you a windowsapplication window on the left goto references and click the add button to get the firmarta.dll in here to.
Making the connection toolbar....you might want to inlarge the form1 window.
1a) Open toolbox and goto menus & toolbars and drag a toolstrip to your window,
b) On the strip you just draged (as long as its still active) there is a little drop menu on it click it and select A label,
now on the right side at bottom is the properties of the said label you just made,
were it saids Text ToolStripLabel1 we are gona call it "Connect".
c) Now back to to the little drop menu wich is now next to connect choose a Separator,
d) Next choose another label and call it "port",
e) Next we will choose a ComboBox the name for this is under design and well call it "ComList",
f) Next another label and call this one "Rate",
g) Next choose another ComboBox and well call this "Baud",
h) now a button (right click button and put it on txt only) this needs altering twice at design section in propertys near bottom we need a we will call this "Connection" ,
now we got more to do here further up in the text bit (just under image with a cross next to it) name it "Connect" and we want to change the image to none.
i) next choose another label and call this one under text "No board connected" then under design name it "Status".
Quick rundown- toolstrip1/Separator/label1/combox1/label2/combox2/button1/label3, do this before adding the code or it will screw the toolstrip
ref - http://msdn.microsoft.com/en-us/library/eyzd6e34(v=vs.80).aspx
Now thats done....
On the right hand side is your solution window, click on the black form1.vb icon and a brown form1 will drop double click on it and a new form1 page will come up.
NOW FOR THE CODE...just past it over your form1, its the same as we just did but its got the extras.
Form1.VB
Imports Firmata
Public Class Form1
Dim arduino As FirmataVB
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
FillCOMsCombo()
FillBaudCombo()
UpdateToolStrip()
'If FirmataVB1 IsNot Nothing Then
'FirmataVB1.Connect("COM4", 115200)
'End If
End Sub
Public Sub FillCOMsCombo()
COMList.Items.AddRange(FirmataVB1.COMPortList())
COMList.Text = Firmata.FirmataVB.DEFAULT_COM_PORT
' or set it to the COM port property of this instance of FirmataVB ...
' COMList.Text = FirmataVB1.PortName
End Sub
Public Sub FillBaudCombo()
Baud.Items.AddRange(FirmataVB1.CommonBaudRates())
Baud.Text = Firmata.FirmataVB.DEFAULT_BAUD_RATE
' or set it to the Baud property of this instance of FirmataVB
' Baud.text = FirmataVB1.Baud
End Sub
Private Sub COMList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles COMList.Click
If COMList.Text <> "" Then
FirmataVB1.COMPortName = COMList.Text
End If
End Sub
Private Sub Baud_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Baud.Click
If Baud.Text <> "" Then
FirmataVB1.Baud = CInt(Baud.Text)
End If
End Sub
Private Sub Connection_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Connection.Click
If Connection.Text = "Connect" Then
FirmataVB1.Connect(COMList.Text, CInt(Baud.Text))
FirmataVB1.QueryVersion()
UpdateToolStrip()
Else
FirmataVB1.Disconnect()
UpdateToolStrip()
End If
End Sub
Public Sub UpdateToolStrip()
If (COMList.Text <> "" And Baud.Text <> "") And FirmataVB1.PortOpen() = False Then
Connection.Enabled = True
Connection.Text = "Connect"
Status.Text = ""
Status.BackColor = Color.Green
COMList.Enabled = True
Baud.Enabled = True
ElseIf FirmataVB1.PortOpen() = True Then
Connection.Enabled = True
Connection.Text = "Disconnect"
' Need a property of FirmataVB to get port name in use
Status.Text = FirmataVB1.PortName() & " is connected"
Status.BackColor = Color.LightPink
COMList.Enabled = False
Baud.Enabled = False
Else
Connection.Enabled = False
Connection.Text = "Connect"
Status.Text = ""
Status.BackColor = Color.Green
COMList.Enabled = True
Baud.Enabled = True
End If
End Sub
Private Sub FirmataVB1_VersionInfoReceieved(ByVal majorVersion As Integer, ByVal minorVersion As Integer) Handles FirmataVB1.VersionInfoReceieved
' Update label or other control in thread safe way
' to display Major and Minor version info
Debug.Print("Majorversion: " & majorVersion & " Minorversion: " & minorVersion)
End Sub
End Class
Under your black form1.vb icon click that again and there will be the Form1.Designer.vb double click on that and past the code in.
Part 2
Form1.Designer.vb
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Me.FirmataVB1 = New Firmata.FirmataVB(Me.components)
Me.ToolStrip1 = New System.Windows.Forms.ToolStrip()
Me.ToolStripLabel1 = New System.Windows.Forms.ToolStripLabel()
Me.ToolStripSeparator1 = New System.Windows.Forms.ToolStripSeparator()
Me.ToolStripLabel2 = New System.Windows.Forms.ToolStripLabel()
Me.COMList = New System.Windows.Forms.ToolStripComboBox()
Me.ToolStripLabel3 = New System.Windows.Forms.ToolStripLabel()
Me.Baud = New System.Windows.Forms.ToolStripComboBox()
Me.Connection = New System.Windows.Forms.ToolStripButton()
Me.Status = New System.Windows.Forms.ToolStripLabel()
Me.ToolStrip1.SuspendLayout()
Me.SuspendLayout()
'
'FirmataVB1
'
Me.FirmataVB1.Baud = 115200
Me.FirmataVB1.BoardType = Firmata.FirmataVB.Board.DUEMILANOVE
Me.FirmataVB1.COMPortName = "COM4"
Me.FirmataVB1.WithAnalogReceiveEvents = True
Me.FirmataVB1.WithDigitalReceiveEvents = True
Me.FirmataVB1.WithVersionReceieveEvents = True
'
'ToolStrip1
'
Me.ToolStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripLabel1, Me.ToolStripSeparator1, Me.ToolStripLabel2, Me.COMList, Me.ToolStripLabel3, Me.Baud, Me.Connection, Me.Status})
Me.ToolStrip1.Location = New System.Drawing.Point(0, 0)
Me.ToolStrip1.Name = "ToolStrip1"
Me.ToolStrip1.Size = New System.Drawing.Size(621, 25)
Me.ToolStrip1.TabIndex = 0
Me.ToolStrip1.Text = "ToolStrip1"
'
'ToolStripLabel1
'
Me.ToolStripLabel1.Name = "ToolStripLabel1"
Me.ToolStripLabel1.Size = New System.Drawing.Size(106, 22)
Me.ToolStripLabel1.Text = "Connection:"
'
'ToolStripSeparator1
'
Me.ToolStripSeparator1.Name = "ToolStripSeparator1"
Me.ToolStripSeparator1.Size = New System.Drawing.Size(6, 25)
'
'ToolStripLabel2
'
Me.ToolStripLabel2.Name = "ToolStripLabel2"
Me.ToolStripLabel2.Size = New System.Drawing.Size(63, 22)
Me.ToolStripLabel2.Text = "Port:"
'
'COMList
'
Me.tscbCOMList.Name = "COMList"
Me.tscbCOMList.Size = New System.Drawing.Size(121, 25)
'
'ToolStripLabel3
'
Me.ToolStripLabel3.Name = "ToolStripLabel3"
Me.ToolStripLabel3.Size = New System.Drawing.Size(63, 22)
Me.ToolStripLabel3.Text = "Rate:"
'
'tscbBaud
'
Me.Baud.Name = "Baud"
Me.Baud.Size = New System.Drawing.Size(121, 25)
'
'Connection
'
Me.Connection.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text
Me.Connection.ImageTransparentColor = System.Drawing.Color.Magenta
Me.Connection.Name = "Connection"
Me.Connection.Size = New System.Drawing.Size(56, 22)
Me.Connection.Text = "Connect"
'
'Status
'
Me.Status.Name = "Status"
Me.Status.Size = New System.Drawing.Size(116, 15)
Me.Status.Text = "No board connected"
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(621, 530)
Me.Controls.Add(Me.ToolStrip1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ToolStrip1.ResumeLayout(False)
Me.ToolStrip1.PerformLayout()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents FirmataVB1 As Firmata.FirmataVB
Friend WithEvents ToolStrip1 As System.Windows.Forms.ToolStrip
Friend WithEvents ToolStripLabel1 As System.Windows.Forms.ToolStripLabel
Friend WithEvents ToolStripSeparator1 As System.Windows.Forms.ToolStripSeparator
Friend WithEvents ToolStripLabel2 As System.Windows.Forms.ToolStripLabel
Friend WithEvents COMList As System.Windows.Forms.ToolStripComboBox
Friend WithEvents ToolStripLabel3 As System.Windows.Forms.ToolStripLabel
Friend WithEvents Baud As System.Windows.Forms.ToolStripComboBox
Friend WithEvents Connection As System.Windows.Forms.ToolStripButton
Friend WithEvents Status As System.Windows.Forms.ToolStripLabel
End Class