You need to have installed Java on the Beaglebone Black before you try this. Please follow the steps at this Running Java Applications on the Beaglebone Black or watch the following YouTube video:
Now that we have this working at the command line it would be useful if we could write programs that interface to the LEDs in a similar fashion. My Java implementation code is below. It uses the Java.io libraries to read and write data to the input/outputs using sysfs.
Effectively, this code carries out the exact same steps as what I did in the first part of this post; however, now it is wrapped up as a command that we can add to our $PATH in order that it can be called from any location. Build this code on your desktop computer or use the class file that I have distributed in the bin directory. The way you execute this code on the Beaglebone Black is to go to the directory below ee402 and type:
I have made all of the code available via github, so you can download this by the following steps:
The way we can interact with GPIOs is not much different than this; however, we have complexities to deal with to do with the Device Tree, and we have to use Device Tree Overlays. See my post: GPIOs on the Beaglebone Black using the Device Tree Overlays on this topic.