Re: [Tutor] Python GPIO Code Help Needed

2014-10-26 Thread Danny Yoo
>> def changed(channel): >> newstate = GPIO.input(channel) >> change = oldstates[channel] and not newstate >> oldstates[channel] = newstate Hi Bill, I would suggest documenting the intent of this function, as it isn't obvious at first. A comment string would be approp

Re: [Tutor] Python GPIO Code Help Needed

2014-10-26 Thread Dave Angel
Please use text mail for posting, and please use reply-list, or whatever your mailer calls it when adding to a thread. So far, you've got at least 3 threads covering a single topic. Bill Bright Wrote in message: > > The code below seems to work. My question is why does oldstates need to be

Re: [Tutor] Python GPIO Code Help Needed

2014-10-26 Thread Alan Gauld
On 26/10/14 22:42, Bill Bright wrote: Thanks to all for the help. The code below seems to work. My question is why does oldstates need to be multiplied by 32? Its creating 32 instances of True. So you can cater for up to 32 different switch positions. will only read 32 switch changes? That

Re: [Tutor] Python GPIO Code Help Needed

2014-10-26 Thread Bill Bright
Thanks to everyone for the help. The code below seems to work. My question is why does oldstates need to multiplied by 32? Does this mean that the code will only work for 32 switches before I have to reset the Pi? Code: #!/usr/bin/env python from time import sleep import os import RPi.GPIO as G

Re: [Tutor] Python GPIO Code Help Needed

2014-10-26 Thread Alan Gauld
On 26/10/14 01:05, Bill Bright wrote: The code polls the GPIO pins on a Raspberry Pi. > When it detects a switch being flipped, it plays a corresponding audio file. Does that mean in either direction? Or does it only play when the switch goes ON? (I'm not familiar with the Pi (although some

Re: [Tutor] Python GPIO Code Help Needed

2014-10-26 Thread Anish Tambe
On Sun, Oct 26, 2014 at 6:35 AM, Bill Bright wrote: > I have been working on a piece of code that I got from another tutorial. > The code polls the GPIO pins on a Raspberry Pi. When it detects a switch > being flipped, it plays a corresponding audio file. My problem is, if the > switch remains fl

Re: [Tutor] Python GPIO Code Help Needed

2014-10-26 Thread Crush
Could this work? /usr/bin/env python import os import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPIO.setup(23, GPIO.IN) GPIO.setup(24, GPIO.IN) GPIO.setup(25, GPIO.IN) pin_list = ['GPIO.input(23)', 'GPIO.input(23)', 'GPIO.input(23)'] for item in pin_list: if item == false: os.system('mpg321

Re: [Tutor] Python GPIO Code Help Needed

2014-10-26 Thread Dave Angel
Bill Bright Wrote in message: > I have been working on a piece of code that I got from another tutorial. The > code polls the GPIO pins on a Raspberry Pi. When it detects a switch being > flipped, it plays a corresponding audio file. My problem is, if the switch > remains flipped, the audio rep

Re: [Tutor] Python GPIO Code Help Needed

2014-10-26 Thread Dominik George
Hi, >if ( GPIO.input(23) == False ): >os.system('mpg321 -g 95 a.mp3') while not GPIO.input(23): pass ... would be the simplest solution. -nik ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription opt