LeaoC
Posts: 3
Joined: Sat May 09, 2015 10:16 pm

GPIO Music Box

Sat May 09, 2015 10:23 pm

Hey everyone,

I'm extremely new to RP and coding in general.

However, I recently bought a RP2 and was trying one of the projects in the Org Website, the GPIO Music Box:https://www.raspberrypi.org/learning/gpio-music-box/.

I was successfully able to do my first two buttons work. However, all other buttons that I try adding to the music box fail to produce sound when pressed.

I've switched buttons to see if that worked but still the only ones producing sounds were the ones connected to pins 2 and 3 on the GPIO. Also, whenever I'm wiring the cables, when I mistakenly put ground on the breadboard in to the " positive rail", the buttons worked (not that well, but they did work).

Am I missing something? Is it because of this error that I'm getting?
"Warning (from warnings module):
File "/home/pi/musicbox/musicbox.py", line 28
GPIO.setup(pin, GPIO.IN, GPIO.PUD_DOWN)
RuntimeWarning: A physical pull up resistor is fitted on this channel!"


Any help is appreciated! thanks! :D

flashkinx
Posts: 1
Joined: Fri Jan 23, 2015 1:39 pm

Re: GPIO Music Box

Tue Jul 21, 2015 3:23 pm

I have exactly the same issue. Are the Pins 2 and 3 the only possible Pins for Pull Down Buttons? :?:

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 13142
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: GPIO Music Box

Tue Jul 21, 2015 5:52 pm

Pins 2, and 3, are normally used for I2C communications, and therefore have pullup resistors that are needed for I2C.
That means that you only need to add a button to these GPIO's, when open the pullup raises the voltage on the GPIO to 3,3 Volt, closing the button lowers it to 0 Volt.
Without a pullup resistor, the GPIO pin isn't lifted to 3,3V, so will drift toward 0V, so between 0V and 0V the software can see no difference.

If you want to use any of the other GPIO's to read a button, you need to add a pullup resistor to 3,3V yourself!
Any value between 1K5, and 100K will work, I recommend using 4K7.

I also recommend wiring a 100 Ohm resistor in series with the button, for safety.
This prevents accidents when software has programmed the GPIO to output 3,3V, and you "short" that voltage to GND with the button.

Return to “Beginners”