Esempio n. 1
0
class Thread_PD(QThread):
    pd_changed_signal = pyqtSignal(int)

    def __init__(self, parent=None):
        super().__init__(parent)
        self.sensor_pd = Button(8)  #####buttun默认 is_active

    def run(self):
        # self.initial_status = self.sensor_pd.value
        while True:
            self.sensor_pd.wait_for_active()
            self.sensor_pd.wait_for_inactive()
            print(self.sensor_pd.value)
            self.emitsignal()
            # time.sleep(0.1)

    def pressed(self):
        print("pressed")

    def emitsignal(self):
        self.pd_changed_signal.emit(1)
from gpiozero import Button, LED

tlacitko = Button(21)
cervena = LED(13)

i = 0
while True:
    tlacitko.wait_for_active()
    i += 1
    if i == 11:
        cervena.toggle()
        i = 0
    tlacitko.wait_for_inactive()
from gpiozero import LED, Button

l = LED(17)
b = Button(27)

while True:
    b.wait_for_active()
    l.toggle()
    b.wait_for_inactive()