
-----------------------------------
valy
07 Ian 2012 02:03


-----------------------------------
Deci first step first: comunicatia PC<->arduino prin USB (defapt e un COM serial).

De pe PC trimit comenzi (C#):

using System.IO.Ports;
...
SerialPort port = new SerialPort("COM5", 9600, Parity.None, 8, StopBits.One);
port.Open();
port.Write("Hello world!");
port.Close();
...

Pe arduino primesc si trimit inapoi (ceva gen C):

void setup() {
  // initialize serial:
  Serial.begin(9600);
}

void loop() {
}

void serialEvent() {
  while (Serial.available()) {
    // get the new byte:
    char inChar = (char)Serial.read(); 
    //send it back 
    Serial.write(inChar);
  }
}

In mod surprinzator merge din prima (testat pe Win7 x64).
