How to enable one Arduino port using C #?

I have an Arduino Duemilanove USB. I have only one LED connected to one port on it. I want to use C # to turn on this LED. Is there a simple example of how to do this? The simplest on / off code is what I'm looking for.

On the side of the note, I know that there are several libraries written to communicate .NET with Arduino. The ones I found use Firmata , and I can't get the Firmata library to work with my Arduino at all, so I'm looking for a simple example using only the serial command.

+3
source share
6 answers

I think the .NET form for interacting with Arduino will answer your question.

+5
source

Try setting the data transfer speed to 57600 instead of the standard 115200, and we hope that Firmata will work with your Duemilanove. I'm honestly still trying to choose the Firmata library for Python to understand how it uses the protocol, so I can use it over direct serial communications in a project that will not only use Arduino as an interface.

In the meantime, however, this led to the operation of Firmata (the path of least resistance).

+1
source

# Arduino , , .

0

COM-. :

System.IO.Ports.SerialPort port = new SerialPort("COM4"); //COM4 is my port. You can use yours.
port.Write(new byte[]{1},0,1);
port.Close();

Arduino:

    if (Serial.available() > 0)
    {
        val = Serial.read();
        if(val==1)
        {
            //LED ON
        }
        if(val==0)
        {
            //LED OFF
        }
    }

, 1 , , , 0.

0

Zelectro .NET Wrapper Arduino

:    ;    System.Threading;    Zelectro;

namespace ZelectroDemo
{
    public class Test3Program : ArduinoProgram
    {
        private LED led;

        public override void setup()
        {
            led = new LED(Pin.PWM11);
        }

        public override void loop()
        {
            led.Blink(50);
        }
    }
}

https://github.com/d3n4/Zelectro

-1

, Firmata - , .

Firmata - . -. . . , Arduino . , Arduino .

:

Firmata.Net Project

Arduino/firmata Visual #.NET

-2

Source: https://habr.com/ru/post/1716402/


All Articles