Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to Resolve Python Looping Function Error?

    • 0
    • 0
    • 0
    • 1
    • 0
    • 0
    • 0
    • 109
    Answer it

    I am running a script that runs once and stops. How do I loop it infinitely?

     

    import time
    outpins =  [ 4,  5,  6, 12, 13, 17 ]
    inpins =  [ 18, 22, 23, 24, 25, 26 ]
    import RPi.GPIO as GPIO
    GPIO.setmode(GPIO.BCM)
    nlines = 6

    time.sleep(1.0)
    for i in range(0,nlines):
        GPIO.setup(inpins[i], GPIO.IN, pull_up_down = GPIO.PUD_DOWN)

    for i in range(0,nlines):
        GPIO.setup(outpins[i], GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
    bad = 0
    for i in range(0,nlines):
        GPIO.setup(outpins[i],GPIO.OUT)
        GPIO.output(outpins[i], GPIO.HIGH)
        if(GPIO.input(inpins[i])==0):
            bad = 1
            cross = 0
            for j in range(0,nlines): # if it looks open cehck for cross links
                if(j!=i):
                    if(GPIO.input(inpins[j])==1):
                        print "cross linked %d to %d" % (i, j)
                        cross = 1
            if(cross==0): # if not cros linked then its just open
                print "line %d open" % i
        for j in range(i+1,nlines):
            if(GPIO.input(inpins[j])==1):
                print "short %d to %d" % (i, j)
                bad = 1
        GPIO.output(outpins[i], GPIO.LOW)
        GPIO.setup(outpins[i], GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
    if(bad==1):
        print "cable is BAD"
    if(bad==0):
        print "cable is GOOD"
     

 1 Answer(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: