I havent found anything, but iam sure there is already info on the topic. So even just a link would be helpful for me.

I want to build a Jukebox. So pretty simple. Around 30 Buttons, if Button is pushed add song to queue. Thats it more or less.

Since Iam a total newbee to pi and python:

How would I add several buttons to the pi? And what would the code roughly look like?

Thanks in advance.

Edit: To add a little more Info, I would need around 100 buttons. As far as I could google this means Iam gonna ned several GPIO extensions(?). How could I get and work with so many signals? The command would be simple for each one.

Maybe USB would be a better option then GPIO for this amount? Iam not to keen on buying 8 extensions boards for 20€ each.

Maybe thing of it as a DIY piano ^^

  • Hello, I'm not sure how much research you've tried but there was a similar question asked a few days ago (for the hardware side): raspberrypi.stackexchange.com/q/96259/93934 Commented Apr 15, 2019 at 9:17
  • Thanks @RogerJones. Its definitly the right direction but I would be more intrested in setting up the keys myself since I dont know yet how much I will use or possibly add more over time. This off ocurse depends on how complex it will be do it myself :)
    – user101499
    Commented Apr 15, 2019 at 10:19
  • 1
    There are thousands of tutorials for connecting buttons to the Raspberry Pi on the www. You need to look through them and choose one. If you then have a problem we may be able to help if you ask a detailed question.
    – joan
    Commented Apr 15, 2019 at 10:54
  • @joan Yeah its true there are a lot of tutorials but I couldnt find one explaning how to connect more switches(buttons then there are GPIO Pins. I already understand that I may need an extension board. But how would i realize the software to such a thing? If you know of any tutorial thats explains this or is similar please tell me :D
    – user101499
    Commented Apr 15, 2019 at 11:43

1 Answer 1


You could simply wire the buttons up as a matrix, your usecase already describes the buttons being placed in a grid pattern. If you wire all the button pins vertically and horizontally you can form a matrix, with the 28 GPIO pins avalible on all Pi models but the first edition. You should be able to theoretically run 14^2 buttons or aprox 196 buttons.

The way this would be run is, you would have an infinite loop that would constantly power 1 column at a time, then while that column was powered if any of your row pins recieved power you would know that a button was depressed and you would know the (x,y) coordinates of said depressed button. You can read more about the concept here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.