connecting more than 20 buttons/leds on the GPIO

March 4, 2024, 13:16

enclave.dll

hi i am making a console that will have buttons and leds more than 20 and they will function with python but the problem is that i dont know how to extend the pins i think i need the product on the picture attached to this message if you can or cannot help please answer your help will be appreciated i will also need some help with the python part like the way it will read each 40 pins on the extender...



enclave.dll

i will also pay with paypal 20 euros to the one who helped

justdaniel1337

Idk how to help you but why do you need 20 or more buttons??? Are you playing in the 5 dimension 💀😂

enclave.dll

yeah its a tardis console

enclave.dll

something like that

justdaniel1337

Oh I see

enclave.dll

its a fan made project

justdaniel1337

I thinks it’s a good way to go

justdaniel1337

You also could use the MCP23017 chip

enclave.dll

and attach it where?

enclave.dll

in the breadboard

justdaniel1337

if you work with a breadboard ye

justdaniel1337

but Im not sure

enclave.dll

i am planning on adding multiple breadboards like 4 of them on the r-pi 4 extender for the main panels and etc etc

justdaniel1337

Yes sure I dont see why not

enclave.dll

now i am just waiting for the components to get delivered

enclave.dll

the problem is how it will work with python

justdaniel1337

idk no I dont work with the raspberry 4 gpio pins xd

justdaniel1337

I would just use r pico's

enclave.dll

whats r pico's difference? sorry i am kinda new to these whole stuff

oops.se

The common way to do this is to put the button in a matrix 4x5 = 20 buttons

justdaniel1337

I'm new too xd but the pico is a microcontroller with gpio pins and its wayyy cheaper than a normal raspi

enclave.dll

ooh okay

oops.se


enclave.dll

i see

oops.se

And then you are using 9 GPIO pins for 20 buttons

justdaniel1337

oh that makes sense ye isn't it like led matrix?

oops.se

Yes and thats called charlieplexing

enclave.dll

each button does a different function in the console i am just reminding you

oops.se

Well that's not a problem, you scan the keys, example: Set pin 1 horizontal line HIGH, then you read the vertical lines one by one and detect a key press. Then you continue with pin 2 horizontal line and 3 and 4

oops.se

There are many example codes and probably libraries as well for your programming language in how to do this

enclave.dll

all right

enclave.dll

i dont really fully undestand it

enclave.dll

but i got a small idea

oops.se

And by adding a diode for each button you will improve the circuit, read more here https://www.gammon.com.au/forum/?id=14175

enclave.dll

ill do my best and let you know if it worked

enclave.dll

so i dont need an extender

enclave.dll

?

oops.se

If you have 9 GPIO pins you can make a 4x5 matrix = 20 buttons

enclave.dll

understood

enclave.dll

so what components should i use for charlieplexing?

enclave.dll

do i need some sort of a chip?

enclave.dll

Also we might have a problem not sure because i am new but as i can see right here we might wont be able to control what every button does and what and how many led lights on when the button pressed...

oops.se

This is NOT charlieplexing, thats LEDs

enclave.dll

its getting clearer thanks for that m8 i appreciate your patience

oops.se

All learning has its steps. I was where you where some years ago so...

enclave.dll

yeah you don't get born with knowledge i have more questions for later on now i have to go for a while

enclave.dll

will this work?

enclave.dll

i've added a led matrix that will actually be interactable with the buttons

enclave.dll

wait a minute the led matrix is 4x1 instead of 4x5 oh for god shake sorry

enclave.dll

there you go i fixed it

enclave.dll

is the code correct? will each button toggle one led?

oops.se

idk

enclave.dll


oops.se

Why post a picture of text?

enclave.dll

uhm its just me talking to gemini ai

enclave.dll

the problem is how will i set up the circuit like where and how should i put the leds and how the negative and positive will be connected to each led same with the buttons

enclave.dll

Could you give me an image on how i should set this up?

oops.se

Why not post the text as text, think about those that has sight impairment....

enclave.dll

your absolutelly right i am sorry

enclave.dll

there: You're almost correct! Pressing "1" actually affects the first LED in row 1. Here's why: Mapping Mismatch: The provided code defines the ledsRow and ledsColumn lists in a way that creates a slight mismatch between keypad buttons and LED positions. The first element in ledsRow (L21) is connected to the first element in ledsColumn (Led1). However, these elements are labelled as "row 0" and "column 0" respectively, which can be misleading. Actual Behavior: When you press "1," the following happens: The readLine function activates the first row (L1) but checks all columns (C1, C2, C3, C4). If the "1" button is pressed, the first element in ledState is toggled, affecting the state of Led1. However, based on the mapping, Led1 corresponds to row 1, column 0 in the LED matrix. Therefore, pressing "1" actually affects the first LED in row 1, column 0 of the LED matrix. The naming convention in the code can be a bit confusing, so it's important to pay close attention to the actual mapping between button positions and LED positions.

enclave.dll

is that circuit diagram correct isn't this a 4x4 matrix? also R represents the resistors +---+---+---+---+---+---+---+---+---+---+---+---+---+---+ | R1|LED1| R2|LED2| R3|LED3| R4|LED4| | | | | | | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+ | R5|LED5| R6|LED6| R7|LED7| R8|LED8| | | | | | | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+ | R9|LED9|R10|LED10|R11|LED11|R12|LED12| | | | | | | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+ |R13|LED13|R14|LED14|R15|LED15|R16|LED16| | | | | | | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+

enclave.dll

<@796000224690307072> how should i connect this 4x4 matrix in the raspberry pi 4 B?

oops.se

I have provided you with a URL earlier that explains it in details

enclave.dll

which one?

oops.se

The one above in the conversation

justdaniel1337

You should use IN instead of OUT? It’s a button right?

enclave.dll

now ive setted up my raspberry pi 4 B and it says faild to open device 'sdcard'

enclave.dll

never mind i needed a keyboard bruh

enclave.dll

now its downloading the os but its tooooo slow like 7 kbps