Controlling eletronic devices with JAVA ( LEDS, MOTORS...)
All this week I try to find some help about how to control eletronic devices like leds using the parallel or serial port using JAVA. Using C it's very simple, but with JAVA, I guess that NOBODY do this kind of application... If I'm wrong, please, tell me.... ( I know that I need to use javax.comm or JNI, but I want to see a real application that works ...
First thing to note is that using javax.comm you cannot set pin outputs
levels directly (you can set some pin levels directly such as CTS and
RTS on a serial port). There are ways around this such as writing the correct byte value to the parallel port (depends on port type though)
Therefore the device you wish to communicate with should be able
to talk to parallel or serial ports. If this is the case you just send
messages to the device and it lights up you leds.
A, perhaps better, solution would be to write, or obtain from the
internet, some native lib that allows bit bashing on the port of your
choice. Then write a wrapper class for it an call its methods (JNI).
This is only worth while if you have some reason to use java rather
then another language, such as C or C++, to talk to you device. This
whole thing would probably be easier in one of those languages.