In this project, we will use potentiometer to control the volume of music player. As raspberry pi can not accept analog signal from potentiometer , we need to use ADC module to convert analog signal to digital signal before sending it to Raspberry Pi.
A/D converter pin graph:
MCP3008 datasheet:https://osoyoo.com/driver/MCP3008_datasheet.pdf
MCP3204 /MCP3208 datasheet:https://osoyoo.com/wp-content/uploads/2016/10/MCP3208_datasheet.pdf
Wiring diagram(MCP3208 or MCP3008):
Wiring diagram(MCP3204)
potentiometer pin graph:
Software installation:
1)Install python on Raspberry Pi by running following terminal commands:
sudo apt-get update
sudo apt-get install python-dev
2) Install RPi.GPIO module by running following commands:
sudo apt-get install python-setuptools
sudo easy_install rpi.gpio
3)Install ALSA sound utilities and MP3 player by running following commands:
sudo apt-get install alsa-utils
sudo apt-get install mpg321
4) Download python code for this project:
wget http://osoyoo.com/driver/raspi-adc-pot.py
chmod 777 raspi-adc-pot.py
run the project:
1) Upload sound module:
sudo modprobe snd-bcm2835
sudo amixer cset numid=3 1
2)Download sample MP3 music files
wget http://osoyoo.com/driver/long_time_no_see.mp3
mpg321 long_time_no_see.mp3
3)Open another terminal window and run following command:
sudo python raspi-adc-pot.py
connect your earphone to Raspberry Pi, change volume by adjusting potentiometer and enjoy your music.
DownLoad Url osoyoo.com
You must be logged in to post a comment.
wgetを実行すると以下のErrorが発生します。
pi@raspberrypi:~ $ wget https://osoyoo.com/driver/raspi-adc-pott.py
–2017-09-18 08:01:29– https://osoyoo.com/driver/raspi-adc-pott.py
Resolving osoyoo.com (osoyoo.com)… 158.69.116.108
Connecting to osoyoo.com (osoyoo.com)|158.69.116.108|:80… connected.
HTTP request sent, awaiting response… 404 Not Found
2017-09-18 08:01:30 ERROR 404: Not Found.
raspi-adc-pott.py → raspi-adc-pot.py
「4)Raspberry Piで下記のコマンドを作動して….」の下のファイル名が間違っています。
誤 wget https://osoyoo.com/driver/raspi-adc-pott.py
正 wget https://osoyoo.com/driver/raspi-adc-pot.py
訂正しました、遅くなりました、誠に申し訳ございません。