Running the Code

The following command will start our volume control script. Adjusting the trimpot will printout the OS volume level on the screen.

$ sudo python3 ./code.py

Testing the Volume Control

Opening a second terminal on your Raspberry Pi we can run the "speaker-test" command and listen to the volume change as we turn the trimpot. 

$ speaker-test -t sine -f 440

Controlling MP3 Volume

The mpg123 command can be used to play MP3 files on your Raspberry Pi. We can open an additional terminal and play MP3 files and adjust the volume with the trimpot we have wired up.

$ mpg123 <MP3 filename>

This guide was first published on Jul 29, 2012. It was last updated on Jul 29, 2012.

This page (Run It) was last updated on Jul 20, 2012.

Text editor powered by tinymce.