Arduino <> Firmata <> Visual Basic .NET
Since the release of the .NET Framework version 2.0 the handy SerialPort component has made communicating over the serial port fairly straightforward. Sending and receiving a simple packet of bytes is almost a trivial matter. But what if you want to read and write to and from every pin on your Arduino board. Not a problem. Just spend many, many weeks creating, coding and testing your own serial protocol!
But why bother? A perfectly good general purpose serial protocol already exist in the form of Firmata.org
To use the DigitalPinControl User Control:
Download the FirmataVB_Components.zip folder to your computer http://www.acraigie.com/programming/firmatavb/firmatavb_downloads.html Unzip or extract FirmataVB_Componets.zip
Open the FirmataVB Components folder
Locate the DigitalPinControl.dll file
Copy the DigitalPinControl.dll file to a suitable location. It’s a good idea to place a copy of it in the project folder for your application
Create a new Windows Forms Application using Visual Studio or Visual Basic Express Edition
Right click anywhere on the Toolbox
Select Choose Items…
The Choose Toolbox Items dialog window will open.
Click the Browse… button
An Open dialog will appear.
Navigate to the DigitalPinControl.dll file
Select the DigitalPinControl.dll file
Click the Open button
Click the OK button
The DigitalPinControl control should now appear in the Toolbox
Click and drag the DigitalPinControl control onto a form in your project A DigitalPinControl will appear on the form.
In the Properties pane enter the number of the pin on your Arduino board that you want to associate this control with in the PinNumber property.
If you want to use the techniques for addressing the
DigitalPinControls on your form that is used in the sample application then make sure you enter a unique PinNumber for each DigitalPinControl Drag as many DigitalPinControls onto your form as you need.
For an Arduino Diecimila that would be 11 – for pins 2 to 12. You only need to create a DigitalPinControl for the pins you’re actually using so if you don’t have anything wired to a particular pin don’t create a control for it.
As you enter a number for the PinNumber property you may notice that for certain pin numbers the PWM portions of the control are displayed. The PWM radio button and slider bar will only be displayed on controls that refer to PWM enabled pins on the Arduino. (At the moment only the Diecimila’s pins have been coded into the user control).
If you are using a different board then you might want to open the DigitalPinControl project and change its code to suit your board. Hopefully i’ll get round to adding definitions for other boards soon.
To see how the DigitalPinControl can be used to receive and send digital messages via FirmataVB have a look at the sample applications code.