Hardware
- Arduino Uno
- Potentiometer
- Raspberry Pi 3
- Raspberry Pi Os
- Hifiberry DAC Pro2
Setup
Potentiometer is running on the Arduino, I'm sending the signal through the USB Serial port to the Raspberry Pi. The Code is complete and working on the Arduino and I'm able to get the signal and print it using a python script on the Pi.
I have remapped the signal range from 0-100 on the Arduino side and I'm looking to use this value to control the volume on the raspberry Pi for a music box I am creating.
Issue
I'm currently using this answer found here as a guide. However, when I run the python script I get the following error in the terminal.
"amixer: Unable to find simple control 'Master',0"
But, when I run the command (amixer scontrols) I show a Master, 0 listed. See below
"pi@raspberrypi:~ $ amixer scontrols Simple mixer control 'Master',0 Simple mixer control 'Capture',0"
Why is the script not seeing the hardware or what am I doing wrong? Here is my script in it's current form. Once I can get the volume to change I'll work on making the loop, I'm new to python and trying to learn something, but I've been stuck on this for a few weeks. Any help is greatly appreciated.
#import serial adapter library and asla audio library
import subprocess
import serial
import alsaaudio
#Variables
ser = serial.Serial('/dev/ttyACM0', 9600)
ser.flush()
volume = ser
command = ["amixer", "sset", "Master", "{}%".format(volume)]
subprocess.Popen(command)
#Imports serial value and prints to monitor
while True:
read_serial=ser.readline()
print(read_serial)