f



what is wrong with this script and how do I get the value in a php script

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

import RPi.GPIO as GPIO
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):
	Rij1 = Rij1 + 1
       while PRij1 == False:
            PRij1 = GPIO.input(17)
    
    if (PRij2 == False):
	Rij2 = Rij2 + 1
       while PRij2 == False:
            PRij2 = GPIO.input(18)
    
	if (PRij3 == False):
	Rij3 = Rij3 + 1
       while PRij3 == False:
            PRij3 = GPIO.input(21)
    
	if (PRij4 == False):
	Rij4 = Rij4 + 1
       while PRij4 == False:
            PRij4 = GPIO.input(22)
    
	if (PRij5 == False):
	Rij5 = Rij5 + 1
       while PRij5 == False:
            PRij5 = GPIO.input(23)
    
	if (PRij6 == False):
	Rij6 = Rij6 + 1
       while PRij6 == False:
            PRij6 = GPIO.input(24)
    
	Totaal = Rij1 + Rij2 + Rij3 + Rij4 + Rij5 + Rij6
	print Totaal
0
martijnperdaan
10/12/2014 2:24:52 PM
comp.lang.python 77058 articles. 6 followers. Post Follow

3 Replies
709 Views

Similar Articles

[PageSpeed] 29

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/

0
Dennis
10/12/2014 4:47:00 PM
On Sun, 12 Oct 2014 07:24:52 -0700 (PDT), martijnperdaan@gmail.com wrote:
> 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
>
> import RPi.GPIO as GPIO
> 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):
> 	Rij1 = Rij1 + 1
>        while PRij1 == False:
>             PRij1 = GPIO.input(17)
[snip]

I regret that I can't solve your problem, but perhaps I can move
the conversation in a useful direction.

If this is a question about RPi.GPIO, it would be good to phrase it
as the simplest possible question about RPi.GPIO.  If it's *not* a
question about RPi.GPIO, it would be useful to replace the references
to RPi.GPIO with some artificial substitute, so that people who don't
have RPi.GPIO on their systems can contribute to the discussion.  For
example, I don't know what type of object is returned by GPIO.input.
Your code appears to assume that it's True or False, but I don't know
whether that's a valid assumption.

When asking why something doesn't work, one greatly improves one's
chances of getting a prompt and useful answer if one reveals precisely
(1) what one desires, and (2) what one gets.

Finally, the code you posted is indented in a way that is not legal Python,
leaving people to guess at what you intended to post.

And finally finally, why do you call this a PHP script?  This is a
Python newsgroup.

-- 
To email me, substitute nowhere->runbox, invalid->com.
0
Peter
10/12/2014 5:01:37 PM
On Sun, 12 Oct 2014 07:24:52 -0700, martijnperdaan wrote:

> 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

I can see several pythonic errors in your script, however as for "what is 
wrong", I see no indication from you of what you expect it to do, what 
output you expect, what error messages you get when you try and run it 
etc.

Perhaps a better subject would have been "how to read gpio on raspberry 
pi"

It also helps if you can reduce your code example to the minimum needed 
to demonstrate the error. In this case, I would suggest that once you can 
read one input correctly, you should be able to expand that code to read 
all inputs.

The code below might help (uses 2.x style print):

import RPi.GPIO as GPIO

GPIO.setmode(mode)
GPIO.setup(17, GPIO.IN)

if GPIO.input(17) == GPIO.HIGH:
    print True
else:
    print False

-- 
Denis McMahon, denismfmcmahon@gmail.com
0
Denis
10/12/2014 6:36:08 PM
Reply:

Similar Artilces:

PHP script to get name of file which houses the script?
I have a number of files which contain PHP scripts like: <?php $file_name='mtg10.php'; include 'format_date.php'; ?> The included PHP script uses $file_name to get the last uploaded time stamp of the named file and process it into a displayable line. All that works as intended. What I don't like is the need for $file_name='mtg10.php'; It would be much handier if I could write something like $file_name=getNameOfThisFile(); instead. I've looked, can't find any such function, but maybe I haven't looked in the right references. Is the...

Executing a python script with arguments from a python script
Hi, I need to call a python script, with command line arguments (it is an autonomous script with a __main__), from within another python script. Can I use exec() or execfile() for this? How to pass the arguments? Thanks, Olivier. olaufr@gmail.com wrote: > Hi, > > I need to call a python script, with command line arguments (it is an > autonomous script with a __main__), from within another python script. > Can I use exec() or execfile() for this? How to pass the arguments? > > Thanks, > > Olivier. > Obligatory "ugh." Are you sure you want to do...

Script Script
Ever want to try a little script to see if it will work but don't want to go through the hassle of creating a file with #!/bin/bash at the top and making it executable and running it as ./script-name and then deleting it or moving it? You can use the fc command in bash, but it runs in the current shell, which can cause real problems, and once you've done it, if it is more than one line, or you do anything else in between at the prompt, it's gone. fc also echos the script, which is really ugly and confusing. So I wrote this little script which has been tremendously u...

PHP CGI script to PHP CLI script
This is my problem: I'm using PEAR package Spreadsheet_Excel_Writer to generate Excel files. Everything works fine on my test server and several production servers. But on one production server, generated Excel won't open (and data is actually in it). I can't figure out what's causing the problem (only difference is PHP version 5.1.6 vs 5.2, other required PEAR packages are identical), but I did notice during my investigation that Excel file generates and opens without problem if I execute script from command line (I use dummy PHP script with basic things needed to m...

executing a python script from another python script.
--0-39868385-1086342505=:82565 Content-Type: text/plain; charset=us-ascii Hi Python Guru, I ve created a GUI using Boa constructor and am now trying to execute a python script when pressing a button on the GUI. So, there will then be two main threads running (the GUI thread and the python script thread). The purpose of doing this is to enable selecting python script to be run from the GUI. any helps please... many thanks.. sarmin --------------------------------- Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger --0-39868385-1086342505=:82565 Content-Type: text/html; ch...

Getting return code for a Python script invoked from a Linux shell script
Hi, folks, I have a Python script that is invoked by a shell script. I uses sys.exit() with a parameter within python. The calling script is using this line to get the return code: exit_code = !$ but it fails to get it. What's wrong here? (I am no Linux guru) Thanks in advance Mark On Wed, 23 Sep 2009 09:51:29 -0700, volcano wrote: > The calling script is using this line to get the return code: exit_code > = !$ > > but it fails to get it. What's wrong here? (I am no Linux guru) > Exit code is obtained with $?, not with !$ -- Igor Pozgaj | ipozgaj at gmail.com (G...

How to get a text input value into a php script
Dear all, here is the code: ----------------------------- <tr>         <td>ohne Anmeldung: </td>         <td><input name="vanm" id="vanm" type="checkbox" onclick="DisableTeilnehmerzahl()"></td> </tr> <tr>         <td>Max. Teilnehmerzahl: </td>         <td><input name="vteilz" id="vteilz" type="text" size="1" maxlength="3" ></td> </tr> -------...

run php on a script, from a script
Hi I would like to know if the following is possible and how to do it: 1) I have a "template" .php file on my server, say template.php. It contains some PHP instructions and some HTML 2) I also have a script, script.php 3) When script.php runs, I want it to run php on template.php, and write the resulting html output to a file. I need to say something like: <?php runphp ( 'template.php', 'htmloutput.html' ); ?> and obtain a file, htmloutput.html, with the result of php having run template.php (hope I'm being clear). The problem is, of course, tha...

Postional Parameter getting wrong value from inside scripts
Hello , I have a small problem. I use a script to pass a parameter and i assign it to a variable . Later on , from inside the program if i call another script and pass a paramater,my first $1 is lost . Eg . Content of abc.sh FS=$1 echo $FS ../def.sh SECOND Content of def.sh echo $1 Calling- ./abc.sh FIRST My output is SECOND. I Need to make use of the "FIRST" later on in the same script ( abc.sh ) / Anyone has any idea. Thanks RC On 7 Aug 2006 03:10:51 -0700, "aarcee" <4mystudies@gmail.com> wrote: >Hello , >I have a small problem. I use a script to pa...

Python as active script <script language=python>
I'm using Activestate python, For older version of python, I know that we can register python as active script by registering it through win32comext.axscript.client pyscript.py And to do that I need to change something in this pyscript.py before running pyscript_rexec.py(http://fastq.com/~sckitching/Python/ win32_activeX_pyscript.htm), but I can't find similar thing with python 2.6.2 I can't find the line that need to be changed. Can someone kindly show me how to enable python26 as an active script for IE? Thanks, ...

How to Machine A python script execute Machine B python script?
Anyone know how I can make Machine A python script execute a python script on Machine B ? If you're running on a UNIX platform, one option would be to use SSH to execute the command remotely. Otherwise, you could also use a client/server setup to have the two scripts communicate across the network and trigger actions etc. It may also be possible to remotely execute an application on Windows using the win32api extensions, but I haven't any idea how you'd go about that. Perhaps others can chime in with detailed information if you let us know what kind of platform you're on and ...

why does it not get the value in perl run shell script to call include php file?
two file in the same folder fun.php 775 1.pl #! /usr/bin/perl $i = 0; $decryptCC = `echo '<?php include( "/home/webserve.ca/eselect/ eselect_test/fun.php" ); echo "CC" . dcc( "$i", "" ) . "CC"; ?>' | php -q`; print $decryptCC; 2. fun.php <? function dcc($char) { return "test"; } ?> 3. 1.sh #!/usr/bin/php -q <?php include('fun.php'); echo dcc(1); ?> run ./1.sh get test. 2. run ....

Getting Python to run Python Scripts in cygwin
Hi guys, This may be a cygwin issue but I was hoping to get some answers here as well if someone has fixed this problem before. Basically, I am able to run "python <scriptname>.py" python files in command prompt. Unfortunately, I can't seem to get it to work in cygwin. I always get an error that says: python: can't open file '<scriptname>.py': [Errno 2] No such file or directory I have looked at my environment variables and it seems to be correct. Would be grateful if someone who has gotten python to work correctly on cygwin could point me in the rig...

how do i run another script from my python script
hey there all, i have been looking for a way to run a php command line script from my python script. here is what i want to do: if x = 4: execute php4 testin.php else: execute php4 testout.php and i also need the script to wait untill the php4 script is done (which i think is the default ) before continuing to run. i know this is possible, but how? thanks nephish@xit.net wrote: > hey there all, > i have been looking for a way to run a php command line script from my > python script. > > here is what i want to do: > > if x = 4: > execute php4 testin.p...

Web resources about - what is wrong with this script and how do I get the value in a php script - comp.lang.python

Script (typefaces) - Wikipedia, the free encyclopedia
Casual scripts show a less formal, more active hand. The strokes may vary in width but often appear to have been created by wet brush rather ...

China must follow its own reform script
Can China's authorities loosen up enough for China to complete its economic transition?

The ingenious way ‘Star Trek Beyond’ is making sure its script doesn’t leak online
... but many details about it are still unknown. In fact, it looks like secrecy around the movie is so tight that the actors have customized script ...

Gilead Sciences, Inc. Faces Troubled HCV Scripts as AbbVie Inc Scripts Go Up
Gilead HCV prescriptions decline, while AbbVie sees an increase in HCV scripts.

Google Apps Script: Tracking add-on usage with Google Analytics
... blog Posted by Romain Vialard, a Google Developer Expert and developer of Yet Another Mail Merge , a Google Sheets add-on. Google Apps Script ...

Studio: Tupac Shakur film script was offered by hacker
"Celebrity hacker" allegedly accessed more than 100 email accounts of actors, athletes and media personnel and tried to sell unreleased scripts ...

Bulls flip the script in stunning Christmas Day victory over Thunder
Chicago Tribune Bulls flip the script in stunning Christmas Day victory over Thunder Chicago Tribune The Bulls swept away their negative vibes ...

The Hateful Eight Ending Differences from Script Revealed - Collider
Brian Formo attended a live read of 'The Hateful Eight' in 2014 and he reveals all the ending changes from Quentin Tarantino's script to the ...

John Boyega Says Star Wars Episode VIII Has A Much Darker Script
, then Episode VIII will take cues from The Empire Strikes Back, adopting a darker tone, according [...]

The police protection playbook: how Ohio officials followed the script to the letter
The day ended with impassioned calls for calm; that Cleveland and Ohio residents be respectful and mindful of the process and the inevitable ...

Resources last updated: 1/26/2016 10:22:45 AM