Here are some projects samples of Arduino and Raspberry Pi.
Q: How to control a 12v device from computer through USB cable?
A: Normally, You can use a USB to TTL cable to connect your PC with an Arduino board, e.g Arduino Uno or Arduino Nano board. Plug USB cable into the computer USB port and connect to RX and TX on Arduino board at another end. Now you can use any programming language to send "commands" through serial ports then receive it from the Arduino board and write some responding code in Arduino IDE to control the voltage on out pins. The pins will connect to a relay module and the relay module will then connect to the 12V(or up to 250v) device.
Here are some products used in this project.