User avatar
RaspberryPiBeginners
Posts: 218
Joined: Fri May 11, 2012 6:54 am
Location: Soham, Cambridgeshire
Contact: Website

"GPIO.output(farray, True)" doesn't work

Sat Feb 16, 2013 11:54 pm

I'm trying to turn on multiply LEDs based on vaiables in an array, it does not work as i get this error when using this code.

If i try and run
"GPIO.output(array, True)"
Traceback (most recent call last):
File "test_array.py", line 41, in <module>
GPIO.output(array, True)
TypeError: an integer is required
However if i use below it works.
"GPIO.output(array[0], True)"
I think it's because array outputs [1,2,3] where array[0] outputs 1.

I need to to loop/do for all items in array. Or something like do until array is empty.
Click here for my unofficial YouTube Channel > http://goo.gl/oFYBD

User avatar
bgreat
Posts: 235
Joined: Mon Jan 23, 2012 2:09 pm

Re: "GPIO.output(farray, True)" doesn't work

Sun Feb 17, 2013 12:24 am

As the error message states, function GPIO.output() requires an integer first argument, not an array.

If you want to set an output for all pins in an array, try:

Code: Select all

for pin in array:
  GPIO.output(pin, True)
Enjoy!
Bill

User avatar
RaspberryPiBeginners
Posts: 218
Joined: Fri May 11, 2012 6:54 am
Location: Soham, Cambridgeshire
Contact: Website

Re: "GPIO.output(farray, True)" doesn't work

Sun Feb 17, 2013 8:49 am

That you very much that solved my problem.
Click here for my unofficial YouTube Channel > http://goo.gl/oFYBD

Return to “Python”