How to use java to control the LED lights connected to PC through USB / SerialPort, etc? What equipment should I use?

I want to write a program in Java, which can control the LED light to connect to the "thing" connected to the computer

The Java program will contain 8 toggle buttons in JFrame The button numbers are from 1 to 8. When the button numbered x is pressed, the LED numbered x will turn on; When you click (toggle) the button again, the LED will turn off

Unlike the microcontroller in which we have to load code, the "something" I mentioned just receives a signal from Java (possibly through USB / serialport /...) to control the light For example, Java sets 0000 through serialport_ 0101 (turn on LED 1 and 3 lights) is sent to "something", and then "thing" will "retain" the value until a new signal is sent Each number of this value represents the high / low of the pin on "something". I connect the pin to the LED

"Something" may be similar to a device that can convert "serial port signal" to "binary" and save the "binary" in a register with output pins. I can connect them to LEDs

Is that possible? Is there any equipment like "thing"? What is it? Does anyone have any suggestions? Or are there some better ways to control PC lighting?

Solution

I did something similar with beaglebone black running Android port I designed an Android application that uses the custom Bluetooth low-power API I created to communicate with Ti cc2541 running ble stack

What you need to do is write functions in C / C + + to make the platform hardware calls required to switch I / O Something like toggle LED is enough Then use the Java Native Interface (JNI) to connect the native call to Java JNI creates a library that can be loaded statically

After creating the library, you can call it using Java

For example, in my case, I created a ble API to communicate with native C, which will perform serial read / write operations on my embedded cc2541 ble chip to command it to enter different states These commands are connect / disconnect, write data, and read data Ble API is written in Java and connected to hardware through JNI and driver calls Then I wrote an application using ble API

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>