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

Support for Raspberry Pi Pico #35

Closed
shaylanger opened this issue Apr 25, 2021 · 5 comments
Closed

Support for Raspberry Pi Pico #35

shaylanger opened this issue Apr 25, 2021 · 5 comments

Comments

@shaylanger
Copy link

I recently built a volume control using Deej and a raspberry pi pico, and figured others might find the python code for the pico usefull (if they wanted to build this as well using a pico)

save this code in a file called main.py on the pico and when the pico is plugged in the Deej program will be able to listen to the potentiometers (you will need to adjust the config.yaml to only have 3 sliders)

Note the Pico only has 3 analog pins (26-28) so it only supports up to 3 potentiometers

import machine
import utime

NOISE = 10
POTENTIOMETER_COVERSION = 64.0625610948 #Converts the Pico's 65536 max to match Deej's expected 1023 max
POTENTIOMETERS = [
    machine.ADC(26),
    machine.ADC(27),
    machine.ADC(28)
]
values = [0] * len (POTENTIOMETERS)            

while True:
    results = ""
    for i, potentiometer in enumerate(POTENTIOMETERS):
        
        curr = round(potentiometer.read_u16() / POTENTIOMETER_COVERSION)

        # this check will normalize the results and reduce noise 
        if values[i] > (curr + NOISE) or values[i] < (curr - NOISE):
            values[i] = curr
        
        results = results + str(values[i])
        
        if i != len(POTENTIOMETERS) - 1:
            results = results + "|"
           
    print(results)
    utime.sleep(.2)
@omriharel
Copy link
Owner

Hi @shaylanger, thanks for writing!

This is cool, however I think it's more appropriate for it to be accessible via your fork of deej - you can essentially create your copy of the project and add the relevant code and instructions there, ensuring that any future changes you make continue to live on in that location. If that sounds good to you, perhaps you can do that and then edit the issue to link to your fork?

Please let me know if you have any questions.

@omriharel
Copy link
Owner

Closing for now!

@dadsgone0
Copy link

For some reason, you are the only person ive seen use a pico for a deej build, i could not find anyrthing on a deej pico build anywhere else. Thank you!

@2tondo
Copy link

2tondo commented Apr 8, 2024

I had the same issue as the guy above me, love your work

@akumar48
Copy link

akumar48 commented Apr 9, 2024

Thanks a lot this is awesome!

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

5 participants