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

Ubuntu • getting gpiozero working

$
0
0
Hello, I am very new to using raspberry pis and am currently trying to learn on a pi 5. I have spent the last 6 hours of my life bouncing between forum posts and various error messages before giving up and making a post here.

I am running ubuntu on the pi 5

currently this is my code

import gpiozero as gp
from signal import pause


led = gp.LED(17)
button = gp.Button(27)

def on_button_pressed():
led.on()
print("Button pressed!")

def on_button_released():
led.off()

button.when_pressed = on_button_pressed
button.when_released = on_button_released


whenever i run it it gives me this error
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 302, in _default_pin_factory
raise BadPinFactory('Unable to load any default pin factory!')
gpiozero.exc.BadPinFactory: Unable to load any default pin factory!

so I looked in the docs but have been unable to succesfully get it working
i have tried every example for changing the pin, but i keep getting OSError: unable to determine gpio base

from what i have found this mean something is wrong with /dev/gpiomem, which does not exist on my system, and i have no clue how to add it.

thanks in advance for your help

Statistics: Posted by exhausted_person — Mon Jul 14, 2025 8:26 pm



Viewing all articles
Browse latest Browse all 9194

Trending Articles