GPIO button help.
Started by alexpagans




0 posts in this topic
alexpagans

1 posts 1 threads Joined: Mar 2025
06-04-25, 11:46 -
#1
Hello, I'm possibly being very dim but if someone could help me with my GPIO preset +/- buttons I would be eternally grateful.

Everything else works with my set-up (Raspberry Pi 3B+, 7 segment LCD, mini DAC, sample libraries I've made, WebGui) but I can't get a simple preset up and down button working. I've been trawling the forum/watching videos and tried loads of variations but no luck.

It's also confusing me that every GPIO pin layout that I find for the 3B+ seems to number things differently?

These are the relevant settings I have in configuration.txt. I have 2 buttons each wired to a ground pin with one going to 17 and the other to 18 (I think, see photo).





Code:
# Set True to use a 7-segment display via I2C
# Two versions: original sparkfun display and cheap HT16K33 based ebay version
USE_I2C_7SEGMENTDISPLAY = True
USE_i2c_7SEGMENTDISPLAY_HT16K33 = False
#
# --- above display definitions are mutually exclusive = you can have only one

# Set True to use the GPIO buttons, configure GPIO pins below
USE_BUTTONS = True




######  Mapping of GPIO_pins: adapt to your hardware wiring/setup  #####
# GPIO modules in this build use mode=BCM. Modes cannot be mixed.
# Make sure used devices do not overlap in their pin usage (except power/gnd ofcourse),
# but for unused devices it is safe to keep or delete the definitions here as you like.
# In example below buttons 18&27 overlap# I use a box with buttons&LCD and one with HiFiBerry&Leds.
# Some devices require no mapping here, but do use pins:
#    -- EEPROM      : 0,1
#    -- Serial Port : 14,15
#    -- I2C        : 2,3
#    -- HiFiBerry  : 2,3,18,19,20,21     
#    -- PirateAudio Hat :  5 (Button A), 6 (Button B), 16 (Button X), 24 (Button Y)

#  -- USE_BUTTONS -- ; A valid GPIO value will activate the button
BUT_incr=17    ; Increase button, increases value/proceeds to next menu choice
BUT_decr=18    ; Decrease button, opposite of above.
BUT_sel=xx
BUT_ret=xx





Many thanks!
Alex.


Attached Files Thumbnail(s)