从树莓到Arduino的串行通信与phpSerial不工作


Serial communication from Raspberry to Arduino with phpSerial not working

我开发了一个软件,我需要使用树莓的串口向arduino发送数据。

我使用phpSerial,但不可能知道用这个代码在Arduino上接收到什么数据。我用端口2上的led进行测试,但当我发送此数据时,led不亮。

对树莓

    $serial = new phpSerial;
    $serial->deviceSet("/dev/ttyACM0");
    $serial->confBaudRate(115200);
    $serial->confParity("none");
    $serial->confCharacterLength(8);
    $serial->confStopBits(1);
    $serial->deviceOpen();
    sleep(1);
    $serial->sendMessage("1");
    echo $serial->readPort();
    $serial->deviceClose();

ON ARDUINO

  if (Serial.available() > 0)  {
      readed_char[i] = (char)Serial.read();
      Serial.print(readed_char[i]);
      if (readed_char[0] == '1'){
         digitalWrite(2,HIGH);

       }
    }

谢谢你的帮助

不需要配置硬件握手吗?

你读到readed_char[i],但检查readed_char[0],这是正确的吗?

BTW:英语中没有"已读"