我有这个代码在我的覆盆子pi中,它会产生2个按钮,其中只有1个按钮可以工作,但是底部的按钮不起作用,即使除了相反的功能之外它们完全相同。代码如下。
import RPi.GPIO as GPIO
import time
from tkinter import *
root = Tk()
GPIO.setup(18,GPIO.OUT)
def on():
GPIO.setmode(GPIO.BCM)
GPIO.output(18,GPIO.HIGH)
def off():
GPIO.setmode(GPIO.BCM)
GPIO.output(18,GPIO.LOW)
tob = Button(root, text = "Press to activate", command = on)
tob.grid(row = 0, column = 0)
tofb = Button(root, text = "Press to deactivate", command = offer)
tofb.grid(row = 0, column = 0)
电路工作,因为它打开了led,它的代码不起作用
答案 0 :(得分:1)
可能会改变回调吗?
command = offer
到
command = off