Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPIO PWM example #18

Open
zhivko opened this issue Feb 3, 2024 · 1 comment
Open

GPIO PWM example #18

zhivko opened this issue Feb 3, 2024 · 1 comment

Comments

@zhivko
Copy link

zhivko commented Feb 3, 2024

Product seems promising, but without python libraries for pwm and gpio, it would be hard to use it.

sipeed@lpi3h-4cfe:~$ sudo apt install python3-gpiozero
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
python3-gpiozero is already the newest version (1.6.2-1+b1).
0 upgraded, 0 newly installed, 0 to remove and 67 not upgraded.

And then simple python3 program

from gpiozero import LED
from time import sleep

red = LED(17)

while True:
    red.on()    #turn led on
    sleep(1)    #delay for 1 second
    red.off()   #turn led off
    sleep(1)

gives this error:

sipeed@lpi3h-4cfe:~/Desktop$ python3 motor.py
/usr/lib/python3/dist-packages/gpiozero/devices.py:288: PinFactoryFallback: Falling back from rpigpio: This module can only be run on a Raspberry Pi!
  warnings.warn(
/usr/lib/python3/dist-packages/gpiozero/devices.py:288: PinFactoryFallback: Falling back from lgpio: No module named 'lgpio'
  warnings.warn(
/usr/lib/python3/dist-packages/gpiozero/devices.py:288: PinFactoryFallback: Falling back from rpio: No module named 'RPIO'
  warnings.warn(
/usr/lib/python3/dist-packages/gpiozero/devices.py:288: PinFactoryFallback: Falling back from pigpio: No module named 'pigpio'
  warnings.warn(
/usr/lib/python3/dist-packages/gpiozero/devices.py:288: PinFactoryFallback: Falling back from native: unable to locate Pi revision in /proc/device-tree or /proc/cpuinfo
  warnings.warn(
Traceback (most recent call last):
  File "/home/sipeed/Desktop/motor.py", line 4, in <module>
    red = LED(17)
          ^^^^^^^
  File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 108, in __call__
    self = super(GPIOMeta, cls).__call__(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/gpiozero/output_devices.py", line 200, in __init__
    super(DigitalOutputDevice, self).__init__(
  File "/usr/lib/python3/dist-packages/gpiozero/output_devices.py", line 83, in __init__
    super(OutputDevice, self).__init__(pin, pin_factory=pin_factory)
  File "/usr/lib/python3/dist-packages/gpiozero/mixins.py", line 85, in __init__
    super(SourceMixin, self).__init__(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 540, in __init__
    super(GPIODevice, self).__init__(**kwargs)
  File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 250, in __init__
    Device.pin_factory = Device._default_pin_factory()
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 291, in _default_pin_factory
    raise BadPinFactory('Unable to load any default pin factory!')
gpiozero.exc.BadPinFactory: Unable to load any default pin factory!

Can you share example how how to use PINS on product Longan Pi 3H.

@wu-yue-yu
Copy link
Collaborator

Hi, the pwm driver has no patch for mainline kernel yet.
The GPIO problem is fixed in the newest image, which is 20240226 version, and the instructions for gpio usage is uploaded to wiki, should be seen on wiki today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants