Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

In this tutorial we will show the steps to use OpenDevice LIBs and easily do communication between a Java application and Arduino

...

You can install through the Library Manager, click to the "Sketch" menu and then Include Library > Manage Libraries.

Find OpenDevice and click <Install>

...

Code Block
languagexml
titlepom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>com.example</groupId>
	<artifactId>opendevice-tutorial</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<opendevice-version>0version>[0.1.2-SNAPSHOT<3-SNAPSHOT,1.0.0)</opendevice-version>
	</properties>
	<dependencies>
		<dependency>
			<groupId>br.com.criativasoft.opendevice</groupId>
			<artifactId>opendevice-connection-stream</artifactId>
			<version>${opendevice-version}</version>
		</dependency>
		<dependency>
			<groupId>br.com.criativasoft.opendevice</groupId>
			<artifactId>opendevice-core</artifactId>
			<version>${opendevice-version}</version>
		</dependency>
	</dependencies>
	
    <repositories>
        <repository>
            <id>oss.sonatype.org</id>
            <url>https://oss.sonatype.org/content/repositories/releases</url>
        </repository>
        <repository>
            <id>oss.sonatype.org-snapshot</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </repository>
    </repositories>
</project>

...

Code Block
languagejava
titleDemo.java source
linenumberstrue
import br.com.criativasoft.opendevice.core.LocalDeviceManager;
import br.com.criativasoft.opendevice.core.connectionmodel.ConnectionsDevice;
import brjava.com.criativasoft.opendevice.core.model.Deviceio.IOException;

public class Demo extends LocalDeviceManager {

    public static void main(String[] args) { launch(args); }

    public void start() throws IOException {

        Device led = new Device(1, Device.DIGITAL);

        connect(out.usb()); // Connect to first USB port available

        while(true){
            led.on();
            delay(500);
            led.off();
            delay(500);
        }
    }
}

...