I need to control a LED light from a computer program that I am writing, i.e. I want to turn that light on or off from the computer. Is there some kind of power switch or alike that I can connect to from a computer, e.g. its USB port?
2 Answers
There is a whole world of home automation products that are designed to be computer controlled. Search for "Smart Switch" and you will be overwhelmed with choices and dismayed at the confusing array of options.
Some can be controlled directly over WiFi, others require a "hub" which your computer talks to that then relays the command to the switch.
Buying guides are strictly off-limits here at SE, and a tutorial on HA is way beyond my capabilities and what would fit into an answer box. However, just a little bit of searching will also help you find the various pieces of software available to control the switches and, in many cases, the APIs to allow you to write your own code to do so if that's what's necessary for your use case.
About 20 years back, I built a set of race control lights for my sailing club, which ran six 300 watt spotlights for signalling boats on the water, plus a horn control, and a push button input to record finishing times. I bought a control box off the web for around 80 bucks, which had 4 input channels and 8 outputs (all 240V relays, insulated from the control box), with a serial port control interface. I know they now do a USB version. Simple protocol -- I wrote a Borland C App which set off a timed start sequence for a race so the race officer could concentrate on the sailing.