if case(3): pin = Pin(7, Pin.Out); break if case(4): pin = Pin(11, Pin.Out); break if case(5): pin = Pin(12, Pin.Out); break if case(6): pin = Pin(13, Pin.Out); break if case(7): pin = Pin(15, Pin.Out); break if case(8): pin = Pin(16, Pin.Out); break if case(): # default, could also just omit condition or 'if True' pin = Pin(3, Pin.Out); # No need to break here, it'll stop anyway print LED print pin try: pin.value = 1 ## set pin.value = 1 for on for count in range(0, ontime): ## wait for required time sleep(1) ## waiting! pin.value = 0 ## 1 - pin.value ## set to zero for off pin.unexport() ## release the pin on exit except KeyboardInterrupt: ## what to do if the programme breaks or ctrl-c pin.value = 0 pin.unexport()
#!/usr/bin/python3 import time from quick2wire.gpio import Pin out_pin = Pin(11, Pin.Out) out_pin.value = 0 print ("pin 11 value = ", out_pin.value) try: while True: out_pin.value = 1 - out_pin.value print ("pin 11 value = ", out_pin.value) time.sleep(2) except KeyboardInterrupt: out_pin.unexport()
print( "%d us per bit" % pulseLength) pulse *= 1000 pulse /= pulseLength pwm.setPWM(channel, 0, pulse) pin23= Pin(16, Pin.Out, pull=Pin.PullUp) pin22= Pin(15, Pin.Out, pull=Pin.PullDown) pin23.value=1 pin22.value=0 pwm.setPWMFreq(60) # Set frequency to 60 Hz try: while (True): # Change speed of continuous servo on channel O pwm.setPWM(0, 0, servoMin) # pwm.setPWM(15, 0, servoMin) time.sleep(1) pwm.setPWM(0, 0, servoMax) #pwm.setPWM(15, 0, servoMax) time.sleep(1) pin23.value=1-pin23.value pin22.value=1-pin22.value except KeyboardInterrupt:
#!/usr/bin/python3 from quick2wire.gpio import Pin import time o1 = Pin(11, Pin.Out) o2 = Pin(13, Pin.Out) o3 = Pin(15, Pin.Out) o4 = Pin(16, Pin.Out) for i in range(1,16): o4.value = bin(i)[-1] if len(bin(i))>2 else 0 o3.value = bin(i)[-2] if len(bin(i))>3 else 0 o2.value = bin(i)[-3] if len(bin(i))>4 else 0 o1.value = bin(i)[-4] if len(bin(i))>5 else 0 time.sleep(0.5)
break if case(5): pin = Pin(12, Pin.Out) break if case(6): pin = Pin(13, Pin.Out) break if case(7): pin = Pin(15, Pin.Out) break if case(8): pin = Pin(16, Pin.Out) break if case(): # default, could also just omit condition or 'if True' pin = Pin(3, Pin.Out) # No need to break here, it'll stop anyway # print LED # print pin try: pin.value = 1 ## LED on for count in range(0, numBlinks): ## wait for required time sleep(0.4) ## matching delay to video frame rate pin.value = 1 - pin.value ## invert LED state pin.value = 0 ## switch LED off pin.unexport() ## release the pin on exit except KeyboardInterrupt: ## what to do if the programme breaks or ctrl-c pin.value = 0 pin.unexport()
#!/usr/bin/python3 import sys from time import sleep from quick2wire.gpio import Pin pin = Pin(int(sys.argv[1]) if len(sys.argv) > 1 else 12, Pin.Out) print pin try: pin.value = 1 while True: sleep(1) pin.value = 1 - pin.value except KeyboardInterrupt: pin.value = 0 pin.unexport()
#!/usr/bin/python3 from time import sleep from quick2wire.gpio import Pin pin = Pin(11, Pin.Out) try: while True: pin.value = 1 - pin.value sleep(1) except KeyboardInterrupt: pin.unexport()