Welcome, Guest. Please Login or Register
Arduino IDE for Visual Studio
 
 
When Logging a Support Issue in the Forum, please ensure you have also:-
  • Enabled vMicro > Compiler > Show Build Properties and Verbose
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
Support requests without the output above may be impossible to answer, so please help us to help you
 
  HomeSearch Tutorials & Wiki visualmicro.com LoginHelpRegister  
 
Page Index Toggle Pages: 1
Send Topic Print
Create a GUI for arduino using visual micro in Visual Studio 2013 (Read 7524 times)
Ricardo_OGA
Newbies
*
Offline



Posts: 3
Create a GUI for arduino using visual micro in Visual Studio 2013
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!
Back to top
 
 
IP Logged
 
Kerr Smith
Newbies
*
Offline



Posts: 8
Re: Create a GUI for arduino using visual micro in Visual Studio 2013
Reply #1 - 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).
Back to top
« Last Edit: Mar 17th, 2015 at 8:50am by Kerr Smith »  
 
IP Logged
 
Ricardo_OGA
Newbies
*
Offline



Posts: 3
Re: Create a GUI for arduino using visual micro in Visual Studio 2013
Reply #2 - 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?
Back to top
 
 
IP Logged
 
Kerr Smith
Newbies
*
Offline



Posts: 8
Re: Create a GUI for arduino using visual micro in Visual Studio 2013
Reply #3 - 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.
Back to top
« Last Edit: Mar 17th, 2015 at 6:20pm by Kerr Smith »  
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10387
United Kingdom
Re: Create a GUI for arduino using visual micro in Visual Studio 2013
Reply #4 - Mar 18th, 2015 at 3:23pm
 
Back to top
 
WWW  
IP Logged
 
Ricardo_OGA
Newbies
*
Offline



Posts: 3
Re: Create a GUI for arduino using visual micro in Visual Studio 2013
Reply #5 - Mar 18th, 2015 at 6:48pm
 
Cool.

I really appreciate the fast answers.

Thanks a lot. Smiley
Back to top
 
 
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print