Command Arduino Uno using Ardulink

2019-07-13 02:57发布

I am trying to command my Arduino Uno using Ardulink library in my JAVA Application but without success I don't know what have I missed, here is my code:

Link link = Link.getDefaultInstance();
boolean connected = link.connect("COM6", 57600);
Thread.sleep(2000);
MessageInfo msg=link.sendPowerPinSwitch(17, IProtocol.POWER_HIGH);
Thread.sleep(5000);
link.disconnect();

In arduino example, it uses this functions of the Servo class to command:

attach(port);pinMode(A3,OUTPUT); digitalWrite(A3, HIGH);
write (135)

Here is the exception that I got:

Exception in thread "Thread-2" java.lang.ArrayIndexOutOfBoundsException: 1024
    at org.zu.ardulink.connection.serial.AbstractSerialConnection$SerialReader.run(AbstractSerialConnection.java:224)
    at java.lang.Thread.run(Unknown Source)

0条回答
登录 后发表回答