C# serial communication


i apology bad english (i don't speak fluently).

hi !

i'm new in arduino universe , communicate arduino mega 2560 c# program.
i achieved transmit data c# program arduino can't reverse.

here arduino program (it sends "test" when push button) :

code: [select]
unsigned long buttoncooldown;
int button = 50;

void setup (){

  serial.begin (9600);
  pinmode (button, input);
}

void loop (){

  operateinputs ();
  delay (10);
}

void operateinputs (){

  if (digitalread (button) == 1){

    if (millis()-buttoncooldown > 100) serial.print ("test");
    buttoncooldown = millis();
  }
}


it works on arduino console doesn't on c# program or in c# program made pauls (i download this topic).

my c# program :

code: [select]
using system;
using opennetcf.io.ports;

namespace consoleapp1
{
    class program
    {
        static void main(string[] args)
        {
            serialport port = new serialport("com4", 9600, parity.none, 8, stopbits.one);
            port.open();
            system.threading.thread.sleep(1000); // waiting arduino reset
           
            (int = 0; < 1000; i++)
            {
                console.writeline (port.bytestoread); // write on console zeros, no data received
                system.threading.thread.sleep(100);
            }

            port.close();
        }
    }
}


please me ! it's third day work on problem !  :smiley-cry:
thanks.  :d

this c# question - better suited c# forum (or google has plenty of answers - c# serial communication)


Arduino Forum > Development > Other Software Development > C# serial communication


arduino

Comments

Popular posts from this blog

Flip address is out of range arduino uno r3

Arduino Uno not uploading

Indesign and MathType fonts