Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help me initial project C# GUI #12

Closed
Wisit opened this issue Jan 11, 2016 · 1 comment
Closed

Help me initial project C# GUI #12

Wisit opened this issue Jan 11, 2016 · 1 comment

Comments

@Wisit
Copy link

Wisit commented Jan 11, 2016

Hi all,
Help me initial project.
my arduino nano board has flash StandardFirmata (version 2.4.4) sketch
and my C# code shown here.

using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Solid.Arduino.Firmata;
using Solid.Arduino;

namespace arduino
{
public partial class Form1 : Form
{
ArduinoSession session = null;
SerialConnection connection = null;
IFirmataProtocol firmata = null;
public Form1()
{
InitializeComponent();
label1.Text = ".......";
}

    private void Form1_Load(object sender, EventArgs e)
    {
        connection = new SerialConnection("COM3", SerialBaudRate.Bps_57600);
        session = new ArduinoSession(connection,timeOut: 250);
        firmata = (IFirmataProtocol)session;
        if(session != null)
        {
            Firmware firm = firmata.GetFirmware();
            label1.Text = String.Format("Firmware: {0} {1}.{2}", firm.Name, firm.MajorVersion, firm.MinorVersion);
            BoardCapability board = firmata.GetBoardCapability();
            //firmata.ResetBoard();
            firmata.SetDigitalPinMode(13, PinMode.DigitalOutput);
            firmata.SetDigitalPin(13, false);
            //label1.Text = "Arduino session open";

        }
    }

    private void button1_Click(object sender, EventArgs e)
    {
        session.SetDigitalPin(13, true);
    }

    private void button2_Click(object sender, EventArgs e)
    {
        session.SetDigitalPin(13, false);
    }

    private void Form1_FormClosing(object sender, FormClosingEventArgs e)
    {
        connection.Close();
        session.Clear();

    }
}

}

but not working.

@7ASecond
Copy link

What is it doing and what do you expect it to do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants