i bought a pi 2 B last week with a ready to use 16x2 Display + Keyboard wich i pluged in the gpio pins. It looks exactly like this picture: Looks like my pi When i start the pi, the background display lights up like discribed in the manual here. I tried to use the display or the buttons serveral times with the example code in the manual and others, and i think the gpio pins dont work. Here is my script just to check the input of the buttons. Because its possible that i use the wrong pins, the code checks each of the 26 pins connected. I hold down every button many times, but the script doesnt recieve any change of the pin inputs. Here is my code:

import time 
import RPi.GPIO as GPIO
INPUTS = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
def InitIO():
    for x in range(1,27):
        print x 
        GPIO.setup(x, GPIO.IN, pull_up_down=GPIO.PUD_UP)

print "Pi button test program starting"
print "Standart pin input : "
print INPUTS
while (True):
    for x in range (1,27):
        if INPUTS[x] != GPIO.input(x):
        print "PIN changed : ",x

I tried the Display with some other code, and it doesnt work too. What am I doing wrong ? I execute the script with sudo python test.py Is the Display and the Keyboard broken ? :(

2 Answers 2


I suggest the first thing to do is check to see if the GPIO are still working.

Remove the screen.

Then run either my gpiotest (requires pigpio) or wiringPi's pintest (requires wiringPi).

  • i ran your gpiotest, and it says "Failed user gpios: None" what does it mean ? i installed pigpiod and started the daemon before running the test.
    – v1nc
    Commented Jan 7, 2016 at 23:53
  • @v1nc That means the GPIO are okay. None failed.
    – joan
    Commented Jan 8, 2016 at 4:15

Pin numbering should be defined explicitly, not just 1,2,etc. Also 0 & 1 does not exists on header. For BCM numbering convention these are:

# ports numbers for BCM mode
# caution: 2 & 3 are used for I2C, omit (delete) these if I2C is used for something
# caution: 13 & 14 are used for UART, omit (delete) these if UART is used for something
PORTS = [2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27]

Then you should use something like

for i, port in enumerate(PORTS):
    # setup port direction & internal pull-up
    GPIO.setup(port, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    # setup interrupt movement sense
    GPIO.add_event_detect(port, GPIO.FALLING)

Take a look at my example here, it is a fully working generic example (shown there with three input pins used, which can be expanded on purpose).

Also you should limit the inputs only to those effectively used by switches, it makes no sense to configure and lock them all as GPI input, especially if some of them are to be used (for example) in output mode to control the LCD display (BTW, how is this one connected ?)

  • thanks for your help, i tried your example with the ports given in the manual(4,9,10,23). Port 4 is really working, so i think the buttons are not broken. I also tried the ports you mentioned above, but none of them works. Do you know what i can do now ?
    – v1nc
    Commented Jan 8, 2016 at 16:59
  • Cannot tell without seeing the actual board schematic, but you should do some further hardware investigation. By running the Python code without the external board fitted, if you randomly connect pins 4, 9, 10 and 23 to ground (either RPi physical pins 6, 9, 14, 20, 25 & 30, 34, 39 in B version), the program respond as it should ? (!! take care not to connect accidentally the input pins to pin 2 or 4 (+5V) !!) Then check with an ohmeter the static functionality/connection to ground of the switches on the external board (with the board unmounted and unpowered).
    – secarica
    Commented Jan 8, 2016 at 21:51

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.