Beginners • 6 weeks and out of time

Beginners • 6 weeks and out of time

Hey all people, so sorry I’m unsure the place to publish this. I’ve been engaged on this mission for about 6 weeks now. I’ve had completely no expertise and in some way nonetheless managed to get this level.. however I’m at a loss for time and desperately need assistance. The mission is meant to be a Christmas reward for my husband.

I’m constructing Talaexe’s Modern Day Record Player utilizing a 3d printed mini report participant and little vinyl records. I do not know if I can hyperlink right here (once more, new) nevertheless it’s straightforward to google if wanted for reference — comes up as a YouTube video. I needed to make some modifications to her tutorial. Specifically, I’m operating a PN532 nfc hat. Inside of Thonny, every thing works completely, some duplication warnings however full performance. When I run the script in terminal I get a number of errors. The total mission is in-built a digital surroundings; all libraries and dependencies

Is there a solution to run this completely in Thonny? If so, is it potential to have it run at startup? If not, how can I repair this and have it run at startup?

Code:

#!/usr/bin/env pythonfrom pn532 import *import RPi.GPIO as GPIOimport spotipyfrom spotipy.oauth2 import SpotifyOAuthfrom time import sleep#pn532 = PN532_SPI(reset=20, cs=4, debug=False)pn532 = PN532_I2C(debug=False, reset=20, req=16)#pn532 = PN532_UART(reset=20, debug=False)p3, p7, i0i1 = pn532.read_gpio()DEVICE_ID="xxxxxxxxxxx"CLIENT_ID="xxxxxxxxxxx"CLIENT_SECRET="xxxxxxxxxx"whereas True:    attempt:        # Configure PN532 to speak with MiFare playing cards        pn532.SAM_configuration()                reader=p3, p7, i0i1 = pn532.read_gpio()        sp = spotipy.Spotify(auth_manager=SpotifyOAuth(client_id=CLIENT_ID,                                                       client_secret=CLIENT_SECRET,                                                       redirect_uri="http://localhost:8080",                                                       scope="user-read-playback-state,user-modify-playback-state"))                # create an infinite whereas loop that can at all times be ready for a brand new scan        whereas True:            print("Waiting for report scan...")            uid= pn532.read_passive_target()            print("Card Value is:",uid)                        # DONT embody the citation marks across the card's ID worth, simply paste the quantity            if (uid==b'x04,1x9dxc1*x81'):                                # enjoying a tune                sp.start_playback(device_id=DEVICE_ID, uris=['spotify:track:1rNSCrsOoWyhKH4g47mehU'])                sleep(3)                            elif (uid==b'x04,x17x9dxc1*x81'):                                # enjoying an album                sp.start_playback(device_id=DEVICE_ID, context_uri='spotify:album:4utJOX1ShFfRa6oQA1ADh0')                #sleep(2)                            elif (uid==b'x04x1e*x9dxc1*x81'):                                # enjoying an album                sp.start_playback(device_id=DEVICE_ID, context_uri='spotify:album:6DEjYFkNZh67HP7R9PSZvv')                #sleep(2)                            elif (uid==b'x04x1ax1dx9dxc1*x81'):                                # enjoying an album                sp.start_playback(device_id=DEVICE_ID, context_uri='spotify:album:1NAmidJlEaVgA3MpcPFYGq')                #sleep(2)                            # proceed including as many "elifs" for songs/albums that you just wish to play                # if there may be an error, skip it and take a look at the code once more (i.e. timeout points, no energetic gadget error, and so forth)    besides Exception as e:        print(e)        move    lastly:        print("Cleaning  up...")        GPIO.cleanup()

I’m conscious that the asterisk in "from pn532 import *" may probably result in issues, however I’m not seeing how as altering that results in a complete host of different points.. it does work in Thonny. I’m additionally studying by way of all of this so if theres time for an evidence that’d be superior.

Here’s are the errors I’m getting in terminal

Traceback (most up-to-date name final):
File "/residence/xxxxx/my_venv/lib64/python3.11/site-packages/participant.py", line 3, in <module>
from pn532 import *
File "/residence/xxxxx/my_venv/lib/python3.11/site-packages/pn532/__init__.py", line 10, in <module>
from . import pn532
File "/residence/xxxxx/my_venv/lib/python3.11/site-packages/pn532/pn532.py", line 35, in <module>
import RPi.GPIO as GPIO
ModuleNotFoundError: No module named ‘RPi’

RPI.GPIO is put in. Originally in simply the surroundings however now additionally outdoors the surroundings (certainly one of my duplication warnings I presume)

PN532 is put in, however solely within the surroundings. I can not seem to get it to put in outdoors the surroundings. Changing the asterisk to "i2c" or "pn532" (positioned within the pn532 library, additionally within the surroundings) results in

Traceback (most up-to-date name final):
File "/residence/xxxxx/my_venv/lib/python3.11/site-packages/participant.py", line 11, in <module>
pn532 = PN532_I2C(debug=False, reset=20, req=16)
NameError: identify ‘PN532_I2C’ is just not outlined

It’s saturday 12/21.. If I had extra time I’d proceed looking out throughout Google for assist. But, its taken 6 weeks to get this far and I’m operating round in circles at this level attempting to resolve this.. all assistance is so very a lot appreciated.

Statistics: Posted by just_a_beginner — Sun Dec 22, 2024 3:12 am


Vinyl

through Raspberry Pi Forums https://ift.tt/DdzfojP

December 22, 2024 at 06:06AM