I would like to write a program in JAVA which can control LED lights connecting to "something" that is connected to the computer.
JAVA program will consist of 8 toggle buttons in JFrame. The buttons are numbered from 1 to 8, and when the button with number X is pressed, the LED with number X will be turned on; when that button is clicked(toggled) again, that LED will be turned off.
Unlike microcontrollers that we have to load code into them, "something" I've mentioned just receives signals from JAVA (maybe via USB/SerialPort/...) to control lights. For example, JAVA sends 0000_0101(turns on LED no.1 and 3) to "something" via SerialPort and then "something" will 'keep' that value until a new signal is sent. Each digit of the value represents HIGH/LOW of a pin on "something" which I will connect the pin to the LED.
"Something" may be something like a device that can convert 'serial port signal' into 'binary' and keep that 'binary' in a register which has output pins that I can connect them to LEDs.
Is that possible? Is there a device like "something"? What is it? Does anyone have any suggestion? or some better ways to control lights from PC?
You can control the GPIO pins on a Raspberry Pi with File
operations. See for example this: https://blogs.oracle.com/hinkmond/entry/rpi_and_java_embedded_gpio3 where an LED blinking is done by alternating the output of a pin. So the "something" is the Pi, which you can get for very little money from many different distributors.
Typically though, Java is not the language of choice for low level bit control. Especially with the Raspberry Pi, use Python instead.