2

I have bought this touch screen.

It looks and works great. I wanted to play round making a simple Kivy app with buttons that turn on/off LEDs and relays. But it seems that when the screen is connected (via HDMI and USB, screen has its own PSU), the GPIO pins don't work. The 5V and 3.3V pins work fine and a LED lights up when connected, but switching other pins doesn't work. Nothing happens.

Using this simple script to test:

import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT)
while True:
    print "ON"
    GPIO.output(17, True)
    time.sleep(1)
    GPIO.output(17, False)
    time.sleep(1) 
Greenonline
  • 2,969
  • 5
  • 27
  • 38
jojonl
  • 118
  • 13

2 Answers2

2

You use the setup method to set the mode of a GPIO to be an input or an output.

So

GPIO.setmode(GPIO.BCM)
GPIO.setmode(GPIO.OUT)

should be

GPIO.setmode(GPIO.BCM) # Set Broadcom GPIO numbering mode.
GPIO.setup(17, GPIO.OUT) # Set GPIO as an output.

http://sourceforge.net/p/raspberry-gpio-python/wiki/BasicUsage/

joan
  • 71,852
  • 5
  • 76
  • 108
1

Some of these touchscreens that come with their own images of the OS with the drivers pre-installed don't properly compile the kernels to handle GPIO outputs from python. I had the same problem. I was able to find someone who wrote a touchscreen driver that did not require the pre-installed kernels, thus avoiding the problem. I couldn't tell what the model of the screen was from the link that you provided, so it is likely that my exact solution will not work for you. But see my post below, as it deals with the same problem.

Touchscreen drivers disable GPIO interface in Python

What you will probably find is that you will not be able to make this work unless you can find a way to either re-compile the system kernels with GPIO access, or write your own touchscreen drivers. Now, in the link to the drivers in that post above, the driver's creator does describe exactly how he was able create the drivers, and all the source code is there, so maybe this will be helpful to you.

Since the drivers worked for me, I don't have any further knowledge of the situation, and I don't have any experience with creating system kernels. However, I hope my own experience with these troubles will send you along the right path.

tmwilson26
  • 198
  • 8