Skip to content

Automatically turns my desk speakers on/off when I change the audio output in Windows.

License

Notifications You must be signed in to change notification settings

Gigabyte5671/Speaker-Controller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Speaker Controller

Automatically turns my desk speakers on/off when I change the audio output in Windows.

Well, that's what I'm using this project for anyway. Although, it's essentially just a smart power bar - you can use it to switch any household appliance on/off.


Warning

This project deals with dangerous mains voltages. Do not attempt to replicate this project unless you are experienced with the hazards involved and are using the appropriate safety equipment.


Bill of Materials

Components and materials I used:


Circuit

This is a rough diagram of the circuit I'm using to control the speakers:
full circuit diagram

In reality, all of the discreet components are part of this board, and connected to the Arduino like so:
simple circuit diagram


Code

Arduino

Code for the Arduino is located in the sketch directory.
This program simply listens for characters being sent by the USB host and toggles the relay's state accordingly. If the program receives a '1' the relay is turned on, '0' the relay is turned off. The program also needs to receive a heartbeat message ('2') at least once every 5 seconds for the relay to stay on.

PC

The script to be run on the connected PC is in the controller directory.
This script runs in the background, polling the registry for updates to the default audio output device. When the default device changes to one of the specified "active" devices, it instructs the Arduino to turn the relay on. When the default device changes to one of the specified "inactive" devices, it instructs the Arduino to turn the relay off.

Tip

You can customise the list of "active" and "inactive" audio devices in the config file.

Note

You'll need to run cd controller && npm i before running this script for the first time.


Housing

The models directory contains some housing models that fit with my particular power bar.

You can also find the model source on OnShape.

I printed these with eSun White PLA+, and the following settings:

  • 0.4mm nozzle
  • 0.2mm layer height
  • 3 wall layers
  • 15% infill density

Images

Fully assembled:
The assembled device

The Arduino and relay are slid into the right side of the housing:
Inside the right side of the device

With the cover on, the USB port is accessible from this side of the device:
Inside the right side of the device

On the opposite side, the two ends of the live wire are inserted into the screw terminals on the relay board:
Inside the left side of the device

The terminals can be tightened down through a small hole in the top of the housing:
Top of the device

You can find full-size versions of these images in the images directory.

About

Automatically turns my desk speakers on/off when I change the audio output in Windows.

Resources

License

Stars

Watchers

Forks