Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Create a GUI for arduino using visual micro in Visual Studio 2013 (Read 9404 times)
Ricardo_OGA
Newbies
*
Offline


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


Posts: 3
Joined: Mar 13th, 2015
Re: Create a GUI for arduino using visual micro in Visual Studio 2013
Reply #2 - Mar 17th, 2015 at 5:23pm
Print Post  
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
Joined: Nov 14th, 2014
Re: Create a GUI for arduino using visual micro in Visual Studio 2013
Reply #3 - Mar 17th, 2015 at 6:18pm
Print Post  
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.
« Last Edit: Mar 17th, 2015 at 6:20pm by Kerr Smith »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


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


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

I really appreciate the fast answers.

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