enfieldbullet
Posts: 3
Joined: Mon Jan 28, 2013 8:57 pm

Sound output affecting GPIO/SPI - query

Mon Apr 01, 2013 10:18 am

Hi,

I have a Nokia 5110 display connected as per http://scruss.com/blog/2013/01/19/the-q ... ish-clock/, and an HC-SR04 Ultrasonic distance connected on GPIO14 and GPIO15. (Header pins 8 and 10), and I'm measuring distance and displaying to the display fine using python.
In the meantime, if I play an MP3 file with 'mpg123' to the audio output jack, the intensity of the backlight LED on the display seems to vary in direct proportion to the sound level playing. - This is connected to header pin 12 (GPIO18).

Can anyone tell my why this is happening?

Initially discovered when having a bit of fun using the distance sensor as a sort of 'Theramin', playing a particular MP3 at particular distance - not a great Theramin, but fun bit of code to use the sensor.

Thanks.
Alan.

User avatar
croston
Posts: 708
Joined: Sat Nov 26, 2011 12:33 pm
Location: Blackpool
Contact: Website

Re: Sound output affecting GPIO/SPI - query

Mon Apr 01, 2013 10:38 am

Possibly the fact that hardware PCM_CLK is an alt function of GPIO18. PCM_CLK is used when sending audio to the audio jack (I could be wrong). This will have a similar effect to running hardware PWM on GPIO18 to control the brightness of an LED. As I understand it, hardware PWM on GPIO18 interferes with audio on the jack but not HDMI.

Somebody please correct me if I am wrong here!

enfieldbullet
Posts: 3
Joined: Mon Jan 28, 2013 8:57 pm

Re: Sound output affecting GPIO/SPI - query

Mon Apr 01, 2013 1:51 pm

Thanks for your reply, I think I've confirmed your theory:-
- I rewired the backlight to header pin 18, re-coded for 'wiringpi' pin 5, (GPIO24), and I can now run the display, the ultrasonic sensor, and the MP3 play without messing up the backlight on the display.

Though I'm very much an 'oldie', I'm new to this stuff, and really loving playing with the GPIO stuff. - It gives me a real child like kick for the Pi to interface with the real world in this way!

Many thanks for your time.
Alan.

Return to “Interfacing (DSI, CSI, I2C, etc.)”