org.kjkoster:lego-wedo-java

A Java library for LEGO WeDo and for Vengit SBrick and SBrick Plus.

License

License

Categories

Categories

Java Languages
GroupId

GroupId

org.kjkoster
ArtifactId

ArtifactId

lego-wedo-java
Last Version

Last Version

2.2
Release Date

Release Date

Type

Type

jar
Description

Description

org.kjkoster:lego-wedo-java
A Java library for LEGO WeDo and for Vengit SBrick and SBrick Plus.
Project URL

Project URL

https://github.com/kjkoster/lego-wedo-java
Source Code Management

Source Code Management

https://github.com/kjkoster/lego-wedo-java

Download lego-wedo-java

How to add to project

<!-- https://jarcasting.com/artifacts/org.kjkoster/lego-wedo-java/ -->
<dependency>
    <groupId>org.kjkoster</groupId>
    <artifactId>lego-wedo-java</artifactId>
    <version>2.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.kjkoster/lego-wedo-java/
implementation 'org.kjkoster:lego-wedo-java:2.2'
// https://jarcasting.com/artifacts/org.kjkoster/lego-wedo-java/
implementation ("org.kjkoster:lego-wedo-java:2.2")
'org.kjkoster:lego-wedo-java:jar:2.2'
<dependency org="org.kjkoster" name="lego-wedo-java" rev="2.2">
  <artifact name="lego-wedo-java" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.kjkoster', module='lego-wedo-java', version='2.2')
)
libraryDependencies += "org.kjkoster" % "lego-wedo-java" % "2.2"
[org.kjkoster/lego-wedo-java "2.2"]

Dependencies

compile (6)

Group / Artifact Type Version
com.codeminders : hidapi jar 1.1
com.google.guava : guava jar 21.0
org.projectlombok : lombok jar 1.16.16
org.thingml » bglib-protocol-1.0.3-43 jar 1.2.1-SNAPSHOT
commons-cli : commons-cli jar 1.4
com.fazecast : jSerialComm jar 1.3.11

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

lego-wedo-java

A Java library for LEGO WeDo and for Vengit SBrick and SBrick Plus. It also comes with simple command line utilities to test controlling LEGO WeDo hubs and SBricks from the command line.

Getting Started

Getting started with LEGO WeDo is described here on the lego-wedo-java USB WeDo Wiki.

BLE112 Bluetooth Dongle Permissions Under Linux

By default, the BLE112 Bluetooth dongle is only readable by root and not by regular users.

To grant non-root users to access the BLE112 dongle, create a file named /etc/udev/rules.d/ble112.rules with the following incantation:

ATTRS{idVendor}=="2458", ATTRS{idProduct}=="0001", SUBSYSTEMS=="usb", ACTION=="add", MODE="0666"

Then unplug the Bluetooth dongle and plug it back in. You should now be able to address it.

Playing Sound Clips

Playing sound clips are easy from the original LEGO WeDo software and I have to say it adds a lot to the build, silly as it may seem. Adding sound clips proved both more hard and more easy than I thought.

It is hard to add sound clips because of the rights to the various clip files. Obviously I cannot publish the original LEGO WeDo sounds. Making my own sounds is also not very successful (ahem).

On the other hand, playing a sound clip in Java is really easy.

final File file = new File(fileName);
if (file.exists()) {
    final AudioInputStream sound = AudioSystem.getAudioInputStream(file);
    final Clip clip = AudioSystem.getClip();
    clip.open(sound);
    
    clip.start();
    clip.drain();
    clip.stop();
} else {
    throw new IOException(file + " does not exist");
}

That is all. I thought to add it to the WeDoBricks class, but that would just hide the controls for you. So here it is. I'm not adding sound support to this WeDo library, simply because Java already makes that super easy.

Reference

Versions

Version
2.2
2.1
2.0