After several maddening errors it occurs to me that there is a problem in my GPIO setup, to wit, RPi.GPIO is failing silently.

To test this theory I got my multimeter, set it to volts, put one probe in ground and another probe in the GPIO port (GPIO 17 in this case) and get 0 volts coming through.

Ordinarily I would think there is a loose conection, or a problem with the board (I am using the Adafruit T-Cobbler http://www.adafruit.com/products/1105 ) but I am able to move a servo with this command (using servoblaster) (which does not use the RPi.GPIO library)

echo p1-22=50 > /dev/servoblaster

My question is - am I testing the GPIO correctly? Is there a better way to test if I am getting any current through the GPIO setup?

The code I am using (Python) is as follows

import RPi.GPIO as GPIO
import time


dirPin = 4
stepPin = 17

GPIO.setup(dirPin, GPIO.OUT)
GPIO.setup(stepPin, GPIO.OUT)

for i in range(0, 3):
   GPIO.output(dirPin, 1)
   GPIO.output(stepPin, 1)
   GPIO.output(dirPin, 1)
   GPIO.output(stepPin, 0)   
  • Without any code, there's not a lot we could say, other than "it should work". – Gerben Dec 8 '13 at 12:21
  • Whoops! My bad, I added the code – Steve French Dec 8 '13 at 13:25
  • Just to make sure. BCM GPIO 4 and 17, means physical pin 7 and 11. Can't see anything wrong with the code. Maybe try GPIO.setmode(GPIO.BOARD) (and change pinnumbers to 7 & 11 of course). Pretty weird. Sorry I can't help. – Gerben Dec 9 '13 at 13:45

One method of testing this would be to connect an LED to the pin and see if you can flash it. I use an LED bar graph like this one from adafruit.

LED bar graph

I mounted this and the corresponding resistors to a piece of stipboard, and added a set of male and female headers to each end (by using both male and female headers on both ends, I can hook it up easily no matter what type of pins the Pi or microcontroller I am testing has). You could do this with plain LEDs as well, but I would suggest at least 8. This allows testing a full port (microntrollers group pins into ports) at once.

One thing I did notice in your code is the long sleep 15000 time:


Was this so you could test the voltage? Because currently you are sleeping for more than 4hrs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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