Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5315

Python • Problem with button.value

$
0
0
I have gpiozero version 2.0-1 on my RPi5.

I wrote a short program in python that works - led and button can cooperate :)

from gpiozero import DigitalInputDevice, LED

led = LED(17)
led.value = 0
button = DigitalInputDevice (27)

while True:
print(button.value)
led.value = not button.value


I want to use a class Button, that have more options than DigitalInputDevice
I change my program to a modified one

from gpiozero import Button, LED

led = LED(17)
led.value = 0
button = Button (27)

while True:
print(button.value)
led.value = not button.value

and I have a problem - button doesn't work and the button.value is always 0.

Maybe somebody has simillar problem and find the solution?

Statistics: Posted by Mugol — Sun May 05, 2024 11:55 am



Viewing all articles
Browse latest Browse all 5315

Trending Articles