コード例 #1
0
def digitalGpioExamples():

	# Set up pin P8_10 as an output
	GPIO.setup("P8_10", GPIO.OUT) # or GPIO.setup("GPIO0_26", GPIO.OUT) referring to the actual pin name instead of header_number
	GPIO.output("P8_10", GPIO.HIGH)
	GPIO.cleanup()

	# Set up pin P8_14 as an input
	GPIO.setup("P8_14", GPIO.IN)

	# Check to see if there is a signal or not and report on the status
	if GPIO.input("P8_14"):
    	print("HIGH")
    else:
    	print("LOW")

    # If you want edge detection instead, look no further (THIS IS BLOCKING, so be aware)
    GPIO.wait_for_edge("P8_14", GPIO.RISING)

    # Non blocking version
    GPIO.add_event_detect("P9_12", GPIO.FALLING)
    #your amazing code here
    #detect wherever:
    if GPIO.event_detected("P9_12"):
    	print "event detected!"
コード例 #2
0
ファイル: ignition.py プロジェクト: Laurenceb/BBB_Launcher
def selftest(debuglevel):
	threshold=340 #150mv threshold
	threshigh=1024 #450mv upper threshold
	ADC.setup()
	ADC.read_raw("AIN4") #Flush this
	baseline=ADC.read_raw("AIN4")
	GPIO.setup("P8_14",GPIO.OUT) #This pin fires the ignition
	GPIO.output("P8_14",GPIO.LOW)
	PWM.start("P8_19",15,49500) #works best with an 11 turn primary
	time.sleep(0.05) #50ms Settling time for the analogue front end
	ADC.read_raw("AIN4")
	selftest=ADC.read_raw("AIN4")
	if selftest>threshold and selftest<threshigh and baseline<128:
		if debuglevel:
			print "Self test ok"
		failure=0		
	else:
		if debuglevel:
			print "Failed"
		failure=1
	PWM.stop("P8_19")
	time.sleep(0.2)
	PWM.cleanup()
	GPIO.cleanup()
	#Debug output
	if debuglevel:
		print baseline
		print selftest
	return {'failure':failure, 'baseline':baseline ,'selftest':selftest }
コード例 #3
0
ファイル: accelerator.py プロジェクト: wedgen/SIUEDSS
def main():
	print "Setting up GPIO"

	accUp = "P8_14"
	accDown = "P8_15"

	# Variables
	GPIO.setup( accUp, GPIO.IN )
	GPIO.setup( accDown, GPIO.IN )
#	GPIO.add_event_detect( accDown, GPIO.BOTH )
#	GPIO.setup( "P9_15", GPIO.OUT )
	global running
	speed = 50

	try:
		print "IN"
		while True:
			t.sleep(.1)
			if GPIO.input( accUp ):
				speed = speed + 5
				print "Speed: %s" % speed
			elif GPIO.input( accDown ):
				if (speed > 0):
					speed = speed - 5
				print "Speed: %s" % speed

	except KeyboardInterrupt:

		GPIO.cleanup()
		print "Ending program"
コード例 #4
0
ファイル: flashers.py プロジェクト: wedgen/SIUEDSS
def main():
	print "Setting up GPIO"

	# Variables
	GPIO.setup("P9_11", GPIO.IN)
	GPIO.add_event_detect("P9_11", GPIO.BOTH)
	GPIO.setup("P9_15", GPIO.OUT)
	global running

	try:

		while True:
			if GPIO.event_detected("P9_11"):
				if GPIO.input("P9_11"):
					print "Hazards on"
					running = True
					t1 = threading.Thread( target = blink_leds, args = ( "P9_15", ) )
					t1.setDaemon( True )
					t1.start()
				else:
					running = False
					print "Hazards off"
					GPIO.output("P9_15", GPIO.LOW)	


	except KeyboardInterrupt:

		GPIO.cleanup()
		print "Ending program"
コード例 #5
0
ファイル: 493.py プロジェクト: dgcarneiro/493
def avoid_():

	

def readfile_coordinates():
	global line
	f = open('temp.txt', 'r')
	temp = f.readlines(line)
	f.close()
	latitude = temp.split("")[0]
	longitude = temp.split("")[1]


while True:
	try:
		while True:
			readfile_coordinates(line)
			scheduler()
			arbiter()
			
	except KeyboardInterrupt: # pressing ctrl C stops operation and cleans up

		PWM.stop(left_wheel)	
		PWM.stop(right_wheel)
		PWM.cleanup()
		GPIO.cleanup()
		ADC.cleanup()
コード例 #6
0
ファイル: readencs.py プロジェクト: eigendreams/esferico
    def __init__(self, node_name_override = 'read_encoders'):
		#
        rospy.init_node(node_name_override)
        self.nodename = rospy.get_name()
        rospy.loginfo("Node starting with name %s", self.nodename) 
        self.rate = float(rospy.get_param("rate", 10))
        # Pines de los encoders
        self.cs1 = "P9_31"
        self.cs2 = "P9_29"
        self.do  = "P9_25"
        self.clk = "P9_23"
        #
        GPIO.cleanup()
        GPIO.setup(self.cs1, GPIO.OUT)
        GPIO.setup(self.cs2, GPIO.OUT)
        GPIO.setup(self.do,  GPIO.IN)
        GPIO.setup(self.clk, GPIO.OUT)
        #
        self.closeComm(self.cs1)
        self.closeComm(self.cs2)
        #
        self.e1val = 0
        self.e2val = 0
        #
        self.e1Pub = rospy.Publisher("e1", Int16)
        self.e2Pub = rospy.Publisher("e2", Int16)
コード例 #7
0
ファイル: stepper_test.py プロジェクト: dotsonlab/awsc
def Blink(numTimes,speed):
    GPIO.output("P8_11", GPIO.LOW)
    for i in range(0,numTimes):## Run loop numTimes
        GPIO.output("P8_7", GPIO.HIGH)
        print "Iteration " + str(i+1)## Print current loop
        GPIO.output("P8_9", GPIO.HIGH)
        time.sleep(speed)## Wait
        GPIO.output("P8_9", GPIO.LOW)
        time.sleep(speed)## Wait
    for i in range(0,numTimes):## Run loop numTimes
        GPIO.output("P8_7", GPIO.LOW)
        print "Iteration " + str(i+1)## Print current loop
        GPIO.output("P8_9", GPIO.HIGH)
        time.sleep(speed)## Wait
        GPIO.output("P8_9", GPIO.LOW)
        time.sleep(speed)## Wait
    for i in range(0,numTimes):## Run loop numTimes
        GPIO.output("P8_7", GPIO.LOW)
        print "Iteration " + str(i+1)## Print current loop
        GPIO.output("P8_9", GPIO.HIGH)
        time.sleep(speed)## Wait
        GPIO.output("P8_9", GPIO.LOW)
        time.sleep(speed)## Wait
    print "Done" ## When loop is complete, print "Done"
    GPIO.output("P8_9", GPIO.LOW)
    GPIO.cleanup()
コード例 #8
0
ファイル: zonkers.py プロジェクト: Zonkers/Whiskers
def zonkers_init_ios():
    """Set the I/O pins to inputs on the beagle bone, so that the zonker board can control them."""

    # The input bits 7 -> 0 are on P8 pins 18  -> 11.
    # The output bits 7 -> 0 are on P8 pins 25 -> 32.

    GPIO.setup("P8_18", GPIO.IN)
    GPIO.setup("P8_17", GPIO.IN)
    GPIO.setup("P8_16", GPIO.IN)
    GPIO.setup("P8_15", GPIO.IN)
    GPIO.setup("P8_14", GPIO.IN)
    GPIO.setup("P8_13", GPIO.IN)
    GPIO.setup("P8_12", GPIO.IN)
    GPIO.setup("P8_11", GPIO.IN)

    GPIO.setup("P8_25", GPIO.IN)
    GPIO.setup("P8_26", GPIO.IN)
    GPIO.setup("P8_27", GPIO.IN)
    GPIO.setup("P8_28", GPIO.IN)
    GPIO.setup("P8_29", GPIO.IN)
    GPIO.setup("P8_30", GPIO.IN)
    GPIO.setup("P8_31", GPIO.IN)
    GPIO.setup("P8_32", GPIO.IN)

    GPIO.cleanup()
コード例 #9
0
ファイル: qb_test_motor.py プロジェクト: delijati/qb_test
def motor_setup(dir1_pin, dir2_pin, pwm_pin):
    """
    Sets up context for operating a motor.
    """
    # Initialize GPIO pins
    GPIO.setup(dir1_pin, GPIO.OUT)
    GPIO.setup(dir2_pin, GPIO.OUT)

    # Initialize PWM pins: PWM.start(channel, duty, freq=2000, polarity=0)
    PWM.start(pwm_pin, 0)

    def run_motor(speed):
        if speed > 100:
            speed = 100
        elif speed < -100:
            speed = -100

        if speed > 0:
            GPIO.output(dir1_pin, GPIO.LOW)
            GPIO.output(dir2_pin, GPIO.HIGH)
            PWM.set_duty_cycle(pwm_pin, abs(speed))
        elif speed < 0:
            GPIO.output(dir1_pin, GPIO.HIGH)
            GPIO.output(dir2_pin, GPIO.LOW)
            PWM.set_duty_cycle(pwm_pin, abs(speed))
        else:
            GPIO.output(dir1_pin, GPIO.LOW)
            GPIO.output(dir2_pin, GPIO.LOW)
            PWM.set_duty_cycle(pwm_pin, 0)

    yield run_motor

    GPIO.cleanup()
    PWM.cleanup()
コード例 #10
0
def cleanup():
    try:
        os.unlink(PID_FILE)
    except:
        pass
    for led in LEDS:
        GPIO.output(led[PIN], 0)
    GPIO.cleanup()
コード例 #11
0
    def cleanup(cls):
        PWM.stop(PWMA)
        PWM.stop(PWMB)
        PWM.cleanup()

        GPIO.cleanup()

        GPIO.output(STBY, GPIO.LOW)
コード例 #12
0
ファイル: QuickBot.py プロジェクト: kingfishar/quickbot_bbb
 def cleanup(self):
     print "Clean up"
     self.setPWM([0, 0])
     self.robotSocket.close()
     GPIO.cleanup()
     PWM.cleanup()
     #         tictocPrint()
     self.writeBufferToFile()
コード例 #13
0
 def test_input(self):
     GPIO.setup("P8_10", GPIO.IN)
     #returned as an int type
     input_value = GPIO.input("P8_10")
     #value read from the file will have a \n new line
     value = open('/sys/class/gpio/gpio68/value').read()
     assert int(value) == input_value
     GPIO.cleanup()
コード例 #14
0
 def set_all_leds(self, state):
     test_leds = { "USR0": "heartbeat", \
                   "USR1": "mmc0", \
                   "USR2": "cpu0", \
                   "USR3": "mmc1" }
     for led, name in test_leds.iteritems():
         self.set_brightness(state, led, name)
         GPIO.cleanup()
コード例 #15
0
 def __init__(self):
   if os.path.exists(self.transmitFIFO) :
     os.unlink(self.transmitFIFO)
   os.mkfifo(self.transmitFIFO)
   os.chmod(self.transmitFIFO, 0666)
   GPIO.cleanup()
   GPIO.setup(self.pin_out, GPIO.OUT)
   GPIO.output(self.pin_out,GPIO.LOW)
コード例 #16
0
ファイル: calibrate.py プロジェクト: antarctica/EMSLED
def finish():
  print "Finished"

  ADC.power_off()
  ADC.stop()

  analogue_IO.disable() # disable TX
  GPIO.cleanup() # free GPIO ports
  exit(0)
コード例 #17
0
ファイル: config.py プロジェクト: alyyousuf7/RollE
def cleanup(signum, frame):
	global exitStatus
	print "\nRollE, signing out."
	exitStatus = True

	sleep(0.2)
	GPIO.cleanup()
	PWM.cleanup()

	exit()
コード例 #18
0
ファイル: PingSensor.py プロジェクト: HeKnOw/Quadie
 def __init__(self):
     #initialize TRIG and ECHO
     self.TRIG = "P8_7"
     self.ECHO = "P8_9"
     GPIO.cleanup()
     GPIO.setup(self.TRIG, GPIO.OUT)
     GPIO.setup(self.ECHO, GPIO.IN)
     GPIO.output(self.TRIG, GPIO.LOW)
     self.ready = False
     self.pulse_start = 0.0
コード例 #19
0
 def test_setup_input_name(self):
     # WARNING: TIMERn syntax is not working on newer kernels
     #          such as 4.4. Originally discovered while testing
     #          Pull Request #152. See issue #156 for details.
     #GPIO.setup("TIMER6", GPIO.IN)
     GPIO.setup("P8_10", GPIO.IN)
     assert os.path.exists('/sys/class/gpio/gpio68')
     direction = open('/sys/class/gpio/gpio68/direction').read()
     assert direction == 'in\n'        
     GPIO.cleanup()        
コード例 #20
0
 def cleanup(self):
     sys.stdout.write("Shutting down...")
     self.setPWM([0, 0])
     self.robotSocket.close()
     GPIO.cleanup()
     PWM.cleanup()
     if DEBUG:
         # tictocPrint()
         self.writeBuffersToFile()
     sys.stdout.write("Done\n")
コード例 #21
0
ファイル: test.py プロジェクト: Necator94/gpio_lib_testing
def adafruitlib():
	b = []
	startTime = time.time()
	for i in range (10000):
		st = time.time()
		state = GPIO.input("P8_12")
		b.append(time.time() - st)
	meanb = sum(b)/len(b)

	print time.time() - startTime, '  mean Adafruit_BBIO', 1/meanb
	GPIO.cleanup()
コード例 #22
0
ファイル: base.py プロジェクト: Muminisko/quickbot_bbb
 def cleanup(self):
     """ Clean up before shutting down. """
     sys.stdout.write("Shutting down...")
     self.set_pwm([0, 0])
     self.robotSocket.close()
     GPIO.cleanup()
     PWM.cleanup()
     if DEBUG:
         pass
         # tictocPrint()
         # self.writeBuffersToFile()
     sys.stdout.write("Done\n")
コード例 #23
0
def blink():
	GPIO.setup('P8_10', GPIO.OUT)
	GPIO.setup('P8_11', GPIO.OUT)

	while True:
		GPIO.output('P8_10', GPIO.LOW)
		GPIO.output('P8_11', GPIO.HIGH)
		time.sleep(1)
		GPIO.output('P8_10', GPIO.HIGH)
		GPIO.output('P8_11', GPIO.LOW)
		time.sleep(1)
	print GPIO.cleanup()
コード例 #24
0
ファイル: test_gpio.py プロジェクト: vaesumed/Muse-BBB
def main():
    """
    @brief Main
    """
    GPIO.setup("P8_10", GPIO.OUT)
    
    while True:
        GPIO.output("P8_10", GPIO.HIGH)
        time.sleep(0.5) 
        GPIO.output("P8_10", GPIO.LOW)
        time.sleep(0.5)    
    
    GPIO.cleanup()
コード例 #25
0
def main():
    t = time.time()
    lastTrigger = time.time()
    while True:
        if not GPIO.input(pin):
	    currTime = time.time()
	    print "Low detected : ",currTime,"Difference ",(currTime - lastTrigger)
	    if (currTime - lastTrigger) > 5:
            	print "Touch that event file here"
                writeTime()
                time.sleep(2)
		lastTrigger = currTime
    GPIO.cleanup()
コード例 #26
0
ファイル: lidar.py プロジェクト: Christihan/Hokuyo
def linea_l(x1,y1,x2,y2,disp,a1,b1):
       
    dis1=((x1-x2)**2+(y1-y2)**2)**0.5
    cv2.line(img,(x1,y1),(x2,y2),(75,50,100),5)
    
    if dis1 > disp:
        disp=dis1
        a=((x1+x2)/2)
        b=((y1+y2)/2)
	       
        cv2.circle(img,(a,b),5,(45,0,255),1) 
        
        if (disp<537*480.0/3000.0):
            
            print 'Distancia',disp
            print ("No es vaca")

        if (disp>=537*480.0/3000.0) and (disp<=543*480.0/3000.0):
            
            if a>a1 and b>b1:
                a1=a
                b1=b  
            print 'Punto medio',a1,b1
            anglew= np.arctan(y2-y1/x2-x1)	
            print 'Angulo',anglew
            print 'Distancia',disp
            print ("Solo hay una vaca")
            GPIO.output("P8_10",GPIO.HIGH)
            time.sleep(0.5)
            GPIO.cleanup()
                             
        if (disp>543*480.0/3000.0):   
            
            print 'Distancia',disp
            print ("Hay mas de una vaca")     
            xa=x1+543*480/300*np.cos(np.arctan(y2-y1/x2-x1))
            yb=y1+543*480/300*np.sin(np.arctan(y2-y1/x2-x1))
            a1=(xa+x1)/2
            b1=(yb+y1)/2
            print 'Punto medio',a1,b1                  
        
    return [disp,a1,b1]
コード例 #27
0
ファイル: start.bak.py プロジェクト: awong36/PWMcontrol
def main():
    global status
    status = -1  # up = 1, down = 0
    motor = pinConfig()
    motor.setPin()

    if GPIO.input(motor.upperSW):  # if on upperSW move down
        print "@Upper switch..."
        status = motor.moveDOWN()
    elif GPIO.input(motor.lowerSW):  # if on lowerSW move up
        print "@Lower switch..."
        status = motor.moveUP()
    else:
        print "@Middle..."
        status = motor.moveUP()

    # print "GPIO event enabled"
    GPIO.add_event_detect(motor.upperSW, GPIO.RISING, bouncetime=1000)
    GPIO.add_event_detect(motor.lowerSW, GPIO.RISING, bouncetime=1000)

    try:
        while True:
            # print status
            if status == 1:
                if GPIO.input(motor.upperSW) and GPIO.event_detected(motor.upperSW):
                    print "@Upper switch..."
                    motor.moveStop()
                    print "... ... Sleep ZZZzz"
                    time.sleep(pinConfig.restTIme)
                    status = motor.moveDOWN()

            elif status == 0:
                if GPIO.input(motor.lowerSW) and GPIO.event_detected(motor.lowerSW):
                    print "@Lower switch..."
                    motor.moveStop()
                    print "... ... Sleeping ZZZzz"
                    time.sleep(pinConfig.restTIme)
                    status = motor.moveUP()

    except KeyboardInterrupt:
        motor.moveStop()
        GPIO.cleanup()
コード例 #28
0
ファイル: gcalendar.py プロジェクト: nathantsmith/Waterboy2.0
def main():
  print('OpenSprinkler Beagle has started...')

  GPIO.cleanup()
  # setup GPIO pins to interface with shift register
  GPIO.setup(pin_sr_clk, GPIO.OUT)
  GPIO.setup(pin_sr_noe, GPIO.OUT)
  disableShiftRegisterOutput()
  GPIO.setup(pin_sr_dat, GPIO.OUT)
  GPIO.setup(pin_sr_lat, GPIO.OUT)

  shiftOut(station_bits)
  enableShiftRegisterOutput()

  while True:
    try:
      runOSBo()
    except:
      pass
    time.sleep(60)  # check every 60 seconds
コード例 #29
0
ファイル: Incubadora_v2.py プロジェクト: nahr91/EmuIncubator
	def __init__(self):
		
		self.Tdes=36.25
		self.periodo=10.0
		self.maxTemp = 36.4  #Emu    #37.8   #Gen
		self.minTemp = 36.1  #Emu    #37.6   #Gen
		self.maxHumi = 29    #Emu    #55     #Gen
		self.minHumi = 26    #Emu    #50     #Gen

		self.stop=1

		self.st1='Bombilla ceramica Off'
		self.st2='Ventiladores Off'
		self.st3='Humidificador Off'
		self.SHT15 = BB_SHT15_lib.BB_SHT15()
		time.sleep(0.5)
		self.motorDC = motor.motor()
		time.sleep(0.5)
		self.iTemp = self.SHT15.temperature()
		time.sleep(0.5)
		self.iHumi = self.SHT15.humidity()

		LOW = 0
		HIGH = 1
		self.motorDC.preexecute() # Starting PWM for the EN of the motors
		self.motorDC.motorSpeed(39)
		GPIO.setup("P8_22", GPIO.OUT) # Motor giro Derecha
		GPIO.cleanup()
		GPIO.setup("P8_23", GPIO.OUT) # Motor giro Izquierda
		GPIO.cleanup()

		GPIO.setup("P8_26", GPIO.OUT) # RELE TEMP
		GPIO.cleanup()
		GPIO.setup("P8_27", GPIO.OUT) # RELE HUMI
		GPIO.cleanup()
		GPIO.setup("P8_28", GPIO.OUT) # RELE HUMI
		GPIO.cleanup()
		self.lastiTemp=0
		self.estado=0
		time.sleep(0.5)
コード例 #30
0
ファイル: ITOP.py プロジェクト: rshin808/ITOPCalibration
def disable(parameters = None):
    """
        Name:   disable 
        Desc:   This disables the Main Power for the board.
        Params: parameters (list)
                    None
    """
    global EN

    for key in PINS.keys():
        if key != "MAINPW_EN":
            GPIO.output(PINS[key], GPIO.LOW)

    EN = False

    time.sleep(1)
    GPIO.output(PINS["MAINPW_EN"], GPIO.LOW)
    GPIO.cleanup()

    with open("EN", "wb") as ENFile:
        ENFile.write("0")
    
    print "Main Power Disabled"
コード例 #31
0
 def __destroy__(self):
     self.logger.info("GPIODevice - stopping")
     GPIO.output(self.pinName, self.gpioOff)
     time.sleep(0.250)  
     GPIO.cleanup(self.pinName)
コード例 #32
0
ファイル: Bench4.py プロジェクト: jalvey2/Bench
        global count2
        PermFloR2 = (count2 * 0.53 / deltaT2)

        #print deltaT
        #print flowrate + 'mL/min'
    print 'Time(sec)=\t\t%s' % (deltaT)  # Time in seconds
    print 'Time(sec)=\t\t%s' % (deltaT2)
    print 'F1(mL/min)=\t\t%s' % (PermFloR)  # Flow rate in mL/min
    print 'F1(mL/min)=\t\t%s' % (PermFloR2)  # Flow rate in mL/min
    print
    time.sleep(0.05)


#flow calibration[Test1: 100 drops, 5.28 mL; Test2:  100 drops, 5.3 mL;
#Test3: 100 drops, 5.32 mL]
#Average vol per drop: 5.3 ml/100 drops = .053 mL/drop
try:
    while True:
        if GPIO.event_detected(PIPin):
            countPulse1()
            timecount()
            countPulse2()

        else:
            time.sleep(0.01)

except KeyboardInterrupt:
    GPIO.cleanup()
    #elapsed_time = time.time()
    #deltaT = float(elapsed_time) - float(start_time1)
コード例 #33
0
ファイル: BRM_AP.py プロジェクト: addvaltech/onyx
 def close(self):
     GPIO.cleanup()
コード例 #34
0
def signal_handler(sig, frame):
    if gpio:
        gpio.cleanup()
    exit(0)
コード例 #35
0
ファイル: access.py プロジェクト: hackmanhattan/125kHz-door
 def quit(signum, frame):
     device.ungrab()
     GPIO.cleanup()
     print("Bye")
     exit()
コード例 #36
0
 def release_pump(self):
     GPIO.cleanup()
コード例 #37
0
    def __stop(self):
        GPIO.cleanup()

        self.serialPort.close()
コード例 #38
0
ファイル: actuators.py プロジェクト: laganossi/GeckoBot
 def cleanup(self):
     GPIO.cleanup()
コード例 #39
0
 def cleanup_gpio(event):
     """Stuff to do before stopping."""
     GPIO.cleanup()
コード例 #40
0
            gpio.output(ctrl_pin, gpio.HIGH)

    elif not (nominal_state and secs < opened_secs) and current_state:
        rospy.loginfo("Closing the solenoid")
        current_state = False
        if gpio:
            gpio.output(ctrl_pin, gpio.LOW)


if __name__ == "__main__":

    nominal_state = False
    current_state = False

    if gpio:
        gpio.cleanup()

    rospy.init_node("solenoid_driver", log_level=rospy.DEBUG)
    name = rospy.get_name()

    if not gpio:
        rospy.logwarn(
            "Failed to import Adafruit_BBIO.gpio, running in desktop mode")

    try:
        ctrl_pin = rospy.get_param(name + "/pin")
        opened_secs = rospy.get_param(name + "/opened")
        closed_secs = rospy.get_param(name + "/closed")
    except:
        rospy.logerr("Failed to retrieve configuration from rosparam server.")
        rospy.signal_shutdown("Unavailable config.")
コード例 #41
0
ファイル: Launch.py プロジェクト: andriqueliu/Rocket-Launch
def shutdown():
	all_low()
	GPIO.cleanup()
コード例 #42
0
def teardown_module(module):
    GPIO.cleanup()
コード例 #43
0
                motorA.stop()


    def OFF_callback(channel):  
        if motorA.isRunning:
            print 'Stopping the motor...'
            motorA.stop()
                       
        else:
            print 'Motor is not currently running...' 



    # The GPIO.add_event_detect() line below set things up so that  
    # when a rising edge is detected, regardless of whatever   
    # else is happening in the program, the function 'my_callback' will be run  
    GPIO.add_event_detect(CWswitch, GPIO.RISING, callback=CW_ON_callback, bouncetime=200)  
    GPIO.add_event_detect(CCWswitch, GPIO.RISING, callback=CCW_ON_callback, bouncetime=200)  


    try:  
        print 'Waiting for button pushes...'  
        while True:
            time.sleep(0.01)
            pass
  
    except KeyboardInterrupt:  
        GPIO.cleanup()       # clean up GPIO on CTRL+C exit  
    
    
    GPIO.cleanup()           # clean up GPIO on normal exit  
コード例 #44
0
 def shutdown(self):
     GPIO.cleanup()
     PWM.stop(self._pin_en)
     PWM.cleanup()
     print "Motor driver shutdown complete"
コード例 #45
0
def clean():
    GPIO.cleanup()
コード例 #46
0
ファイル: main.py プロジェクト: mayurpatelgec/AlexaBeagleBone
def signal_handler(signal, frame):
    GPIO.cleanup()
    sys.exit(0)