Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #79003
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Subject | Re: what is wrong with this script and how do I get the value in a php script |
| Date | 2014-10-12 12:47 -0400 |
| Organization | IISS Elusive Unicorn |
| References | <05f27d81-372d-4242-bc62-e738e23680d4@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.14791.1413132432.18130.python-list@python.org> (permalink) |
On Sun, 12 Oct 2014 07:24:52 -0700 (PDT), martijnperdaan@gmail.com
declaimed the following:
>what is wrong with this script and how do I get the value Rij1 and Rij2 and Rij3 and Rij4 and Rij5 and Rij6 in a php script
>
Well, I don't see anything that looks like PHP here...
>import RPi.GPIO as GPIO
Presume this means running on a Raspberry PI... There is a newsgroup
just for them; comp.sys.raspberry-pi
>GPIO.setmode(GPIO.BCM)
>
>GPIO.setup(17, GPIO.IN)
>GPIO.setup(18, GPIO.IN)
>GPIO.setup(21, GPIO.IN)
>GPIO.setup(22, GPIO.IN)
>GPIO.setup(23, GPIO.IN)
>GPIO.setup(24, GPIO.IN)
>
>Rij1 = 0
>Rij2 = 0
>Rij3 = 0
>Rij4 = 0
>Rij5 = 0
>Rij6 = 0
>
>
>while True:
> PRij1 = GPIO.input(17)
> PRij2 = GPIO.input(18)
> PRij3 = GPIO.input(21)
> PRij4 = GPIO.input(22)
> PRij5 = GPIO.input(23)
> PRij6 = GPIO.input(24)
>
> if (PRij1 == False):
Over kill or erroneous depending upon what GPIO.input() actually
returns...
if not PRij1:
is sufficient, since Python treats 0, 0.0, False, [], {}, and None as
"FALSE"
> Rij1 = Rij1 + 1
> while PRij1 == False:
> PRij1 = GPIO.input(17)
This loop is going to block the program from doing ANYTHING until that
input changes to true.
>
> if (PRij2 == False):
> Rij2 = Rij2 + 1
> while PRij2 == False:
> PRij2 = GPIO.input(18)
>
Same for this... And all the rest... You are incrementing a counter
that apparently says the input was low, and then waiting for the input to
go high, regardless of any other inputs.
>
> Totaal = Rij1 + Rij2 + Rij3 + Rij4 + Rij5 + Rij6
You will only get here once ALL inputs have gone True. Totaal will then
contain the count of inputs that were not high when you first read the pins
(for the first cycle of the main loop). Subsequent passes of the main loop
will continue to increment the Rijx for those pins that were low at the top
of the loop.
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
what is wrong with this script and how do I get the value in a php script martijnperdaan@gmail.com - 2014-10-12 07:24 -0700 Re: what is wrong with this script and how do I get the value in a php script Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-10-12 12:47 -0400 Re: what is wrong with this script and how do I get the value in a php script Peter Pearson <pkpearson@nowhere.invalid> - 2014-10-12 17:01 +0000 Re: what is wrong with this script and how do I get the value in a php script Denis McMahon <denismfmcmahon@gmail.com> - 2014-10-12 18:36 +0000
csiph-web