本文整理汇总了Python中GPIO.export方法的典型用法代码示例。如果您正苦于以下问题:Python GPIO.export方法的具体用法?Python GPIO.export怎么用?Python GPIO.export使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GPIO
的用法示例。
在下文中一共展示了GPIO.export方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ledon
# 需要导入模块: import GPIO [as 别名]
# 或者: from GPIO import export [as 别名]
#!/usr/bin/python
from Tkinter import *
import GPIO # importing GPIO library
led = 4 # assigning the gpio_4 to variable led
GPIO.export(led) # exporting the gpio_4
GPIO.setup(led,1) # make the gpio_4 as output pin by the value 1
def ledon(): # function for turning on an led
print "turn on"
GPIO.write(led,1)
def ledoff(): #function for turning off an led
print "turn off"
GPIO.write(led,0)
root =Tk()
button1 = Button(root,text="ON",command=ledon) #assigning the function ledon to the button "ON"
button2 = Button(root,text="OFF",command=ledoff) #assigning the function ledoff to the button "OFF"
button1.pack(side = LEFT ) #alignment for the button "ON"
button2.pack(side = RIGHT) #alignment for the button "OFF"
root.mainloop()