Show Posts
Pages: [1] 2
1  Using Arduino / Interfacing w/ Software on the Computer / Re: Silverlight, Firmata and Arduino on: September 11, 2012, 11:24:41 am
Hi Walt,
When you say "I downloaded MS Visual Studio just to unsandbox the program", I'm a little usure what it is you're trying to do? On my site I use the term 'Sandbox' to refer to a Silverlight application that is running in the browser window. There are security restrictions in place that restrict a browser-based application from accessing local resources on your computer e.g. serial ports. To 'unsandbox' a Silverlight applicaiton means to have it run locally on your computer - not on a web page. A Silverlight application running Out-of-Browser can be granted 'elevated trust' enabling it to access certain local resources on your computer. In the case of the Arduino Firmata Tester that is access to the local 'port' provided by a serial proxy application (what I believe you are referring to by 'serial redirector').

To run a Silverlight application Out-of-Browser, to 'unsandbox' it, you do not need MS Visual Studio. You simply 'install' the application from the web page where you found it. The Arduino Firmata Tester look like this:

And it can be found here:

To use the Arduino Firmata Tester from the site you do not need MS Visual Studio. You need to install it from the page and have a 'serial proxy' application configured and running on your computer. And, by the way, you also need to upload the StandardFirmata sketch onto your Arduino board (I'm assuming you've done that!  smiley)

I have provided all the code that was used to create the Arduino Firmata Tester Silverlight application in the form of a Visual Studio project folder. This is the 'raw' code and assests. It is available as zipped download from the Links page: It is this project that you can open in Visual Studio. When I mentioned above that you can change the Properties for the project it is when you have it open in MS Visual Studio. You only need to open this project in Visual Studio to investigate how it was created or to change or amend it.

When you say 'the program connects but fails to do anything else', what do you mean? For it to do something you will need to have something connected to your Arduino board - LEDs, buttons, potentiometers etc. When you connect the application try clicking the Firmware, Capabilities and Pin Values buttons. Each of these should at least trigger a response from the board if it is indeed connected and running Firmata.


2  Using Arduino / Interfacing w/ Software on the Computer / Re: What's the simplest way to communicate between Arduino & a browser on: September 11, 2012, 06:50:22 am
Hi Jolyon,

You might want to take a look at

"Breakout is a prototyping tool for exploring the intersection of the web and the physical world. The popular Arduino platform and the Firmata protocol are leveraged to enable users to access physical input and output purely from javascript."

found here -
3  Using Arduino / Interfacing w/ Software on the Computer / Re: Silverlight, Firmata and Arduino on: September 11, 2012, 06:18:49 am
Hi carpenterbee,

To run the completed application you click the Install button on the Arduino Firmata Tester Silverlight application on this page: . You install it directly from the web page. 'Installing' it means creating a local copy of the application that will run with elevated trust on your own computer - this is what Out-of_Browser means. An applicaiton running within the browser is 'sandboxed' and unable to communicate with local devices due to security restrictions.

You will be prompted with an install window, simply click the install button. The application will then usually place a shortcut on your desktop. If you have installed and configured Serial Proxy correctly, chosen the correct ports and set the correct baud rate then you'll be good to go.

I'm not too sure what you mean by... "A simple way to create the file to unsandbox your project/program would be nice.". Could you give a little more detail and I'll try to help out.

When working with the project in Visual Studio the option to 'Enable running application out of the browser' is found in the Project Properties page. Project > AndrewCraigie Properties...  You will also find an Out-of-Browser Settings... button here too.

Hope this helps.

4  Using Arduino / Interfacing w/ Software on the Computer / Silverlight, Firmata and Arduino on: August 28, 2012, 01:55:17 pm
Hi all,

I thought I'd share this project I put together recently as part of a Masters Degree course in Networked Multimedia

Silverlight <> Firmata <> Arduino

The website gives an introduction to the use of Arduino, Firmata, a serial proxy and Silverlight.

A C# class has been created that takes care of the Firmata protocol within the Silverlight applicaiton. The complete project code can be downloaded from the website.

Details are given of how to create reusable interface controls for use within Silverlight applications. A couple of examples of the controls are in the images below:

A simple Silverlight application is provided that brings all the elements together and demonstrates how you can directly install an 'out-of-browser' Silverlight application.

All the code is completely open source and you are free to download it, use it and change it in any way.

5  Forum 2005-2010 (read only) / Interfacing / Re: Firmata & REALbasic on: August 25, 2009, 04:31:22 pm
Hi JohnRD,

You are correct. To set Pin 13 to output you send the 3 bytes - Hex values F4 0D 01. To actually set the values or states (on/off) of the digital pins you address an entire port at once. On a Duemilanove board the ports (as Firmata sees them) are set up as follows:

Port 0 - pins 2,3,4,5,6,7
Port 1 - pins 8,9,10,11,12,13

You turn these digital pins on/off by sending a 3 byte message in the following format:
Port | 1st Byte | 2nd Byte

Where Port is 0x90 for Port 0, 0x91 for Port 1 ... (and that's all you need for the Duemilanove it only has that many digital pins)

The 1st and 2nd Bytes are the 'bitmasks' for the port in question. Think of the bits in the 1st and 2nd Byte as individual switches for the pins in that port.

So to send a message to turn on Pin 13 you send:
MessagePort1st Byte2nd Byte
Hex version of message0x910x200x00
Hex and byte bits version0x910010000000000000

The second row in the table shows the Hex values. In the third row I've shown the bits in each byte. Pin 13 is actually the 6th pin in Port 1 so to turn it on you set the 6th bit to a '1'.

Each time you send a digital I/O message you are actually setting the state of ALL the pins in that port. So in the example above, when you turned ON pin 13 the message did turn on pin 13 but it also turned OFF all the other pins (all those other bits set to '0').

To effectively use Digital I/O Messages you have to keep a track of which pins are on or off in your software. If pin 10 is on and you decide to then turn on pin 13 and use the message above you'd be turning pin 13 on but 'accidentally' turning off pin 10.

Below are the bits that correspond to each pin on the board:

Port 0 (pins 2,3,4,5,6,7)
1st Byte                          2nd Byte
X  X 13 12 11 10  9  8      X  X  X  X  X  X  X  X

Port 1 (pins 8,9,10,11,12,13)
1st Byte                          2nd Byte
X  X  6  5   4   3   2  X      X  X  X  X  X  X  X  7

In Port 1 pins 0 and 1 are RX and TX so aren't used. Wherever you see an X above you should always simple send a 0 (zero).

So... let's say you want to turn on pins 13, 11 and 8 you'd send:
0x91 followed by the following 2 bytes of 'bitmasks' - 0 0 1 0 1 0 0 1  0 0 0 0 0 0 0 0
In Hex that'd be 0x91 0x29 0x00.
If you then want to turn off only pin 11 you'd have to send 0x91 followed by 0 0 1 0 0 0 0 1  0 0 0 0 0 0 0 0
Which sets the bit for pin 11 to 0 but leaves the bits for pin 13 and 8 set to 1

I hope this was of some help and that it made sense.

Happy bitmasking,

6  Forum 2005-2010 (read only) / Interfacing / Re: mouse coordinates in to arduino on: April 12, 2009, 03:25:55 pm
Hi again.

Glad to be of help. I don't know much about controlling servos but can give a few comments on the communications part of the code...

In the Visual Basic code I'd suggest you use more than one text box - one for each servo. It would make dealing with what's entered a bit easier.

In the code you currently have if you enter '1180 290' into the same text box then..

       Dim head As Byte = CByte(myString.Substring(1, 1))
        Dim butt As Byte = CByte(myString.Substring(1))
... head will equal 1 and butt will also equal 1!

myString.substring() returns as many characters (not words) as you ask it to. In both of the myString.Substrings you use you're asking for character at index 1 - the second 1 in the string. Strings are zero indexed in VB so the first character of a string is at index 0.

If you want to get the 1180 from the text box you would need the code myString.Substring(0, 4) and to get the 290 from it you would need the code myString.Substring(5, 3).

If, as i'm guessing, you're trying to get the 180 and the 90 then the codes should be...

       Dim head As Byte = CByte(myString.Substring(1, 3))
        Dim butt As Byte = CByte(myString.Substring(6, 2))
...that's assuming you've got a space between the 1180 and the 290.

Whilst this will work it will cause you problems if in future you use values of different lengths. For example if you want the next instruction to be '15 220' then you'd have to write completely different substring codes. Probably easier to have separate text boxes for each servo. Then you wouldn't need to use substrings at all or numbers to identify the servo...

       Dim head As Byte = CByte(TextBox1.Text)
        Dim butt As Byte = CByte(TextBox2.Text)

You would still need to make sure the numbers you were entering in each text box were only between 0-255 as a byte can't hold any more. It would also be a good idea to do some checking of the text entered into the text boxes to make sure they are valid numbers and not letters, spaces or punctuation. If they are you're program will throw all sorts of exceptions. This might help with that

7  Forum 2005-2010 (read only) / Interfacing / Re: mouse coordinates in to arduino on: April 12, 2009, 10:04:42 am

I've had similar problems getting Visual Basic programs and Ardunio to communicate correctly using a serial port. The issue is usually to do with what you are actually sending on the port - ASCII codes or Bytes.

I believe that if you use SerialPort.Write(e.X) then you will be sending an ASCII representation of the value of e.X. When the Arduino code receives this in your sread = it is receiving ASCII codes - these are not integer values that can then be mapped to your pulse values.

I've solved this problem in the past by making sure I send a single Byte from the Visual Basic code. Take your mouse.X value and first convert it to a single Byte. (you'll need to make sure the initial value is between 0 and 255 as a Byte can only hold up to 255). Place this value in a Byte array and then send the single byte from the byte array over the serial port. For example:

       'Single byte to hold mouse.X
        Dim mouseX As Byte
        'Convert the e.X integer into a byte
        mouseX = CByte(e.X)

        'Create a byte array
        Dim buffer() As Byte = {0}
        'Place the mouseX byte in index 0 of the array
        buffer(0) = mouseX

        'Use the write buffer method of the serial port
        'and send the byte at index 0 of the buffer array
        SerialPort1.Write(buffer, 0, 1)

The Arduino will then receive a Byte containing a value from 0 - 255 instead of ASCII code that represents the value.

Hope this helps. At least it seems to work for me.

8  Forum 2005-2010 (read only) / Interfacing / Re: Major help with VB -> Arduino on: February 28, 2010, 05:11:36 am
Hi jith,

Without looking at your entire code and knowing exactly how you've wired up your application I can't really help.

My only suggestion is to download the sample applications and work through these until you have a thorough understanding of how they work.  In essence you need to include the component, create code to establish a COM link (see how this is done in the sample apps - the non 'extended' one should be simpler to follow) and then use code to send messages to the DigitalPin command. The DigitalPinControl component is just a handy way to add the visual functionality to your project. You can simply use the FirmataVB1.DigitalPinWrite as you have been doing in your own code instead.

Hope this helps.


Andrew Craigie
9  Forum 2005-2010 (read only) / Interfacing / Re: Major help with VB -> Arduino on: February 28, 2010, 03:46:40 am
Hi jith,

In code you'd pass the value 1 for on and 0 (digit zero) for off.

10  Forum 2005-2010 (read only) / Interfacing / Re: Major help with VB -> Arduino on: August 27, 2009, 07:32:05 am

Did you create buttons on your form with the same names I used?

You can download the Visual Basic 2008 project I tested the code in here:

I'm not sure what version of Visual Basic you are using but you may not be able to open it in an Express version.

If you can't then work your way systematically through the debug errors and you should get it to work (check the button names first).


Andrew Craigie.
11  Forum 2005-2010 (read only) / Interfacing / Re: Major help with VB -> Arduino on: August 27, 2009, 04:59:44 am
Hi again,

There are two main things that are causing the problem:

1) Timing issues in the Arduino sketch. Adding a delay between reading the serial bytes fixes this
2) You are sending Strings from your VB code. Sending bytes will fix this

A few other minor things that you should be aware of:

  • When using if (Serial.available()) in an Arduino sketch you should use if(Serial.available() > 0) to account for no serial available actually returning a value of -1 which could cause a 'true' even when no serial data is available
  • In the Arduino sketch its a good idea to create variables of the type that the code expects. Using the LED.h library and the led.setvalue() command you should use a byte variable between the brackets. It would probably work with an integer but best to be on the safe side. So it'd be a good idea to use byte colour instead of int colour
  • Read your serial data outside any conditional statements. If for any reason none of the conditions were met the serial buffer would still have the 'colour' data in it the next time through the loop
  • In VB code to send byte values (which is what you want to do) you use an array of bytes (in the code below i've called this sendBuffer but you could call it anything you like.
Anyway... I've included some code below that does work...

Arduino Sketch

#include <EEPROM.h> //
#include <LED.h>    //

LED ledboot_ok = LED(13);//declare digital pin 13 as the boot ok LED.
LED ledr = LED(11);//declare digital pin 11 as a Red LED's.
LED ledb = LED(10);//declare digital pin 10 as a Blue LED's.
LED ledg = LED(9); //declare digital pin 9 as a Green LED's.
// Changed these two variables to bytes instead of integers
byte com;
byte colour;

void setup()
  Serial.begin(9600); // opens the com port and sets it at 9600 baud
  //ledr.setValue(, ledg.setValue(, ledb.setValue(; // sets LEDs and fans to previous settings before it was reset/turned off.
  ledboot_ok.on(); // Turns boot_ok LED on

void loop()
  // changed (Serial.available()) to (Serial.available() > 0)
  if (Serial.available() > 0)
    com =;
    colour =;

    // This is for the red LEDs
    if (com = 1) {
      //EEPROM.write(1, colour);
    // This is for the green LEDs
    if (com = 2) {
      //EEPROM.write(2, colour);
    // This is for the blue LEDs
    if (com = 3) {
      //EEPROM.write(3, colour);

Visual Basic code
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        With SerialPort1
            .PortName = "COM2"
            .BaudRate = 9600
        End With

        Catch ex As Exception
        End Try
    End Sub

    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
            If (SerialPort1.IsOpen()) Then
            End If
        Catch ex As Exception

        End Try
    End Sub

    Private Sub btnAllOff_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAllOff.Click
        SendComPortValue(1, 0)
        SendComPortValue(2, 0)
        SendComPortValue(3, 0)
    End Sub

    Private Sub btnAllOnFull_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAllOnFull.Click
        SendComPortValue(1, 255)
        SendComPortValue(2, 255)
        SendComPortValue(3, 255)
    End Sub

    Private Sub SendComPortValue(ByVal colour As Byte, ByVal PWMvalue As Byte)
        Dim sendBuffer() As Byte = {0, 0}
        sendBuffer(0) = colour
        sendBuffer(1) = PWMvalue

            SerialPort1.Write(sendBuffer, 0, 2)
        Catch ex As Exception

        End Try
    End Sub

End Class

Hope this helps. Good luck with the rest of it.

Andrew Craigie
12  Forum 2005-2010 (read only) / Interfacing / Re: Major help with VB -> Arduino on: August 26, 2009, 07:05:47 am
Hi again,

Not sure what you mean by 'Firmata is not working'!?! I'm assuming you mean it is not working for you and as your post suggests it is not working for you in the way you would like it to. With Firmata running on your Arduino and using the FirmataVB component you could easily implement a small program in VB.NET or C#.NET to send PWM to any/all of the 6 PWM pins on the Arduino. The issue is then one of knowing how to write the .NET application. Forgive me if i'm wrong on this but it seems that is where you're looking for support.

To 'simply' control your LEDs you don't, of course, need to use Firmata. You do however need to create your own protocol and write not only the Arduino sketch to receive it but to write the VB.NET application as well. You've made a start with the Arduino sketch.

A few comments on your Arduino sketch first:

You appear to be trying to set the value of Pin 13 to 255. Pin 13 is not a PWM pin so to turn it on you'd use digitalWrite(ledboot_ok, HIGH) and to turn it off you'd use digitalWrite(ledboot_ok, LOW).

It looks like you want to send values of 1000 - 1225, 2000 - 2225, 3000 - 3255 to the Arduino from your computer. Any of these values would require you to send 2 bytes. Nothing wrong with that but using com = will only read the first byte you send and as your code stands all of the if statements would be false all of the time.

If you're going to write your own sketch (rather than using Firmata) you will need to write it to accept at least 2 bytes at a time.

Something like the following might work:

if (Serial.available())
    // read the first byte (1, 2 or 3)
    LEDtoSet =;
    delay(100);  // this line may not be necessary
    // read the next byte (0 - 255)
    PWMvalue =;

    // code here to then set the LED PWM value
    analogWrite(LEDtoSET, PWMvalue);


Doing it that way you'd have to send 3 seperate 2 byte messages from your computer to set the LEDs. An alternative approach would be to have the Arduino sketch accept a 4 byte message. The first byte would be the RGB 'cluster' number then the next 3 bytes would be the R, G & B values. Slightly more complex Arduino sketch but would cut down on data sent and be easier to implement in VB.

In Visual Basic (or C#) a simple program that does the following would work:

  • Configure a serial port with the name of the port your using and the baud rate your using
  • Open the serial port
  • Send the bytes you want to send

I'd include a some VB code for you but work beckons.


Andrew Craigie
13  Forum 2005-2010 (read only) / Interfacing / Re: Major help with VB -> Arduino on: August 26, 2009, 02:26:54 am
Hi Du-z,

Yes you can modify the Firmata protocol if you want to and you can certainly modify the FirmataVB code for your own needs (you're encouraged to do so)

To turn on/off some LEDs you can use the Standard Firmata sketch as it is. Load this onto your board. Connect LEDs to as many digital pins as you like (pins 2 - 13).

You would then send messages to the board from your software using the Firmata protocol. This is where the FirmataVB code comes in. You would adapt it to do what you want. You can either set up buttons in your VB project to turn on/off LEDs or have the user type in values that the software then sends to the board.

Not sure from you're reply whether you intend trying to control RGB LEDs but if you did you could use the PWM pins to 'mix' the colours.

Anyway, the best way to find out how it all works is to try it out

I'd suggest you...
  • Upload the Standard Firmata sketch to your board
  • Download and extract the ArduinoFirmataVBExtended zip file from the download page at
  • Navigate to the following folder in the download ArduinoFirmataVBExtended\ArduinoFirmataVBExtended\ArduinoFirmataVBExtended\bin\Release
  • Double click the ArduinoFirmataVBExtended.exe file and try this out with a few LEDs connected to your board.

Andrew Craigie
14  Forum 2005-2010 (read only) / Interfacing / Re: Major help with VB -> Arduino on: August 26, 2009, 01:50:08 am
Hi Du-z,

You might want to have a look at the sample applications on this site:

Especially the on the Downloads page. This is a Visual Basic.NET application that communicates to the Arduino which is running Standard Firmata. Firmata is a ready-made protocol for communicating with the Arduino.


15  Forum 2005-2010 (read only) / Exhibition / Re: Arduino <> Firmata <> Visual Basic .NE on: May 06, 2009, 07:07:47 am
Hi designer2k2,

It will work with any numbered COM port. You simply supply the name of the COM port as a string eg. "COM26". You can set this in the Properties pane for the FirmataVB instance at design time or in code.

Check out the ArduinoFirmataVBExtended - sample application. It contains a drop down list in the toolstrip that allows you to choose any COM port to connect to at run time.

Pages: [1] 2