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

Running on a Raspberry Pi 3+ #10

Closed
Miniontoby opened this issue Jan 20, 2023 · 1 comment
Closed

Running on a Raspberry Pi 3+ #10

Miniontoby opened this issue Jan 20, 2023 · 1 comment

Comments

@Miniontoby
Copy link

This issue is only to provide a way to run this on a Raspberry Pi 3+. This may not be added into the source code!

I don't have a Raspberry Pi Pico and I still wanted to be able to try/use this with a normal Raspberry Pi 3+. So I tried to make this code compatible.

Here's how you do it:
Just create a file in your cloned folder named machine.py and paste this code into it:

import RPi.GPIO as GPIO
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)

class PWMchanged(GPIO.PWM):
    def __init__(self, chan, freq):
        super().__init__(chan, freq)
        self.start(freq)
    def duty(self,dutycycle): self.ChangeDutyCycle(dutycycle/65535)
    def freq(self, value): self.ChangeFrequency(value)
    def deinit(self): self.stop()
    pass

def PWM(pin):
    GPIO.setup(pin, GPIO.OUT) # Just to make sure
    return PWMchanged(pin, 50)

def Pin(pin):
    GPIO.setup(pin, GPIO.OUT)
    return pin
@james1236
Copy link
Owner

Thank you, very well integrated! You can add this to the readme as a pull request if you'd like, or I can add it myself

This issue was closed.
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