Visual Studio Ide for Arduino
https://www.visualmicro.com/forums/YaBB.pl
>> >> Create a GUI for arduino using visual micro in Visual Studio 2013
https://www.visualmicro.com/forums/YaBB.pl?num=1426274516

Message started by Ricardo_OGA on Mar 13th, 2015 at 7:21pm

Title: Create a GUI for arduino using visual micro in Visual Studio 2013
Post by Ricardo_OGA on Mar 13th, 2015 at 7:21pm
Hey guys.
How can I create a GUI for arduino using the visual micro in the visual studio 2013?

I know how to create a windows form, but I don't know hot to use it with the visual micro.

Thanks!

Title: Re: Create a GUI for arduino using visual micro in Visual Studio 2013
Post by Kerr Smith on Mar 17th, 2015 at 8:50am
You can use serial to send data to the Arduino - below is a simple bit of code to send individual letters via serial when you click buttons on a form:

Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        SendSerialData("r")
    End Sub
    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        SendSerialData("g")
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        SendSerialData("b")
    End Sub

    Sub SendSerialData(ByVal data As String)
        ' Send strings to a serial port.
        Using com4 As IO.Ports.SerialPort =
                My.Computer.Ports.OpenSerialPort("COM4", 57600)
            com4.WriteLine(data)
        End Using
    End Sub

End Class

If you copy the code from above in to your form you will be able to see how it works - this code just changes the RGB led colour on a button click (you need to code the Arduino to read in this serial data and set the appropriate colour).

Title: Re: Create a GUI for arduino using visual micro in Visual Studio 2013
Post by Ricardo_OGA on Mar 17th, 2015 at 5:23pm
Thanks Kerr.

About the synchronization.

I'll need to create a tread or the SendSerialData and the .ino file are already  synchronized?

Title: Re: Create a GUI for arduino using visual micro in Visual Studio 2013
Post by Kerr Smith on Mar 17th, 2015 at 6:18pm
The Arduino code could look something like this:

const int redled = 9;
const int greenled = 10;
const int blueled = 11;

void clearleds()
{
     analogWrite(redled, 0);
     analogWrite(greenled, 0);
     analogWrite(blueled, 0);
}

void setup()
{
     Serial.begin(57600);
     pinMode(redled, OUTPUT);
     pinMode(greenled, OUTPUT);
     pinMode(blueled, OUTPUT);
}

void loop()
{
     byte colour;

     if (Serial.available())
     {
           colour = Serial.read();

           switch (colour)
           {
           case 'r':
                 clearleds();
                 analogWrite(redled, 200);
                 break;
           case 'g':
                 clearleds();
                 analogWrite(greenled, 200);
                 break;
           case 'b':
                 clearleds();
                 analogWrite(blueled, 200);
                 break;
           }
     }
}

You just need to use the Serial.begin function in the setup function and then the Serial.available() function in the loop function in order to get access to the serial data.

You could trim the code right down so it just turns an LED on and off with a button push on the form to get the hang of how it is working.

Title: Re: Create a GUI for arduino using visual micro in Visual Studio 2013
Post by Visual Micro on Mar 18th, 2015 at 3:23pm
There is also a full example C# and Arduino here

http://stackoverflow.com/questions/10420959/arduino-uno-basics-for-c-sharp/12150222#12150222

Title: Re: Create a GUI for arduino using visual micro in Visual Studio 2013
Post by Ricardo_OGA on Mar 18th, 2015 at 6:48pm
Cool.

I really appreciate the fast answers.

Thanks a lot. :)

Visual Studio Ide for Arduino » Powered by YaBB 2.5.2!
YaBB Forum Software © 2000-2019. All Rights Reserved.