1

I was trying to send a message to Arduino (to test if the Arduino received any message the motor will turn on), the following code works if I run on Terminal

echo 1 > /dev/ttyACM0

But I tried this in Java

Runtime.getRuntime().exec("echo 1 > /dev/ttyACM0");

Anyone knows how to execute in Arduino Serial port?

1

3 Answers 3

1

I used the RXTX lib for Java serial connections.

Very similar code to what worked for me is shown here:

https://embeddedfreak.wordpress.com/2008/08/08/how-to-open-serial-port-using-rxtx/

Sign up to request clarification or add additional context in comments.

Comments

0

Try RXTX library, this is Java wrapper for the serial port. Project website. Example: source

Comments

0

Java doesn't provide support for serial communications out of the box. You need to use a 3rd party library or extension. Oracle do provide one - Java Communications API

http://www.oracle.com/technetwork/java/index-jsp-141752.html

I have used this in the past with AVR Micro-controllers. There are several tutorials on the net to get it up and running.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.