python - Using return in a while loop -


in continuing quest more control, need put interrupt based on end stop gpio pin switch event.

i using return make sure controller change picked when sent, thinking pin 11 event same. pin event not stopping motor.

gpio.setup(gpio_sw1, gpio.in, pull_up_down=gpio.pud_up) gpio.add_event_detect(11, gpio.rising)  def motorcontrol(direction,fspeed,bspeed):   print "motor control: bspeed: " + str(bspeed) +"% : fspeed: " + str(fspeed) + " %"   while not  gpio.event_detected(11):     if direction == "fwd":        print "i forward"        bck.changedutycycle(0)        fwd.changedutycycle(fspeed)        time.sleep(0.01)        return       if direction == "bwd":        print "iam backwards"        bck.changedutycycle(bspeed)        fwd.changedutycycle(0)        time.sleep(0.01)        return        else:      bck.changedutycycle(0)      fwd.changedutycycle(0)   return 


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -