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

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 :)

Code:

from gpiozero import DigitalInputDevice, LEDled = LED(17)led.value = 0button = 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

Code:

from gpiozero import Button, LEDled = LED(17)led.value = 0button = 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 1251

Trending Articles