No such device, circutpython

how do i see it through a folder?

import os
os.listdir('/')
os.listdir('/sd')

how do i use the user buttons?

Pinout for VGA Base

They seem to be grounded

It looks like the VGA base uses the least significant bit of each of the colors with the switches.
image

what?
I dont understand man

I don’t have a VGA base to test but I would think that something like:

import digitalio
import board
buttonA = digitalio.DigitalInOut(board.GP0)
buttonA.direction = digitalio.Direction.INPUT

while True:
    if buttonA.value:
        print("Button A pressed")

would work.

worked thanks
you maybe wondering what my project is, its a mp3 player

import audiobusio
from analogio import AnalogIn
import board
import digitalio
import adafruit_sdcard
import bitbangio
import storage
import os
from audiomp3 import MP3Decoder
from audiocore import WaveFile
spi = bitbangio.SPI(board.GP5,board.GP18,board.GP19)
cs = digitalio.DigitalInOut(board.GP22)
sd = adafruit_sdcard.SDCard(spi,cs)
vfs = storage.VfsFat(sd)
storage.mount(vfs, "/sd")
led = digitalio.DigitalInOut(board.LED)
led.direction = digitalio.Direction.OUTPUT
analog_in = AnalogIn(board.VOLTAGE_MONITOR)
a = audiobusio.I2SOut(board.GP27, board.GP28, board.GP26)
mp3 = open("low.mp3", "rb")
lowd = MP3Decoder(mp3)
wave_file = open("/sd/music/octoboss.mp3", "rb")
wave = MP3Decoder(wave_file)
buttonA = digitalio.DigitalInOut(board.GP0)
buttonA.direction = digitalio.Direction.INPUT

print(os.listdir('/sd/music'))

def get_voltage(pin):
    return (pin.value * 3.3) / 65536

while True:
    print("Clear")
    if buttonA.value:
        print("Button A pressed")
#    while a.playing:
#        pass
    if(get_voltage(analog_in) <= .5):
            if(led.value == True):
                a.play(lowd)
            led.value = False
    else:
#        a.play(wave)
        led.value = True
1 Like

man, ive got low battery detection, audio playing from sd card and i need to add stuff like skipping songs pausing and playing, etc

Sounds neat. You may want to go ahead and re-flash the Pico with the standard Pico CircuitPython firmware. Your code doesn’t use any of the DVI Base custom pin names and the Pico DV Base firmware will try and initalize the DVI display which in the best case wastes some time but could cause issues.

I already did, i reflashed a while ago

1 Like

its not resuming, when i press the button

        if a.playing:
            a.pause()
        elif a.paused:
            print("It should play bruv")
            a.stop()

That sounds like a programming issue. You might want to open a new support topic although you may find more CircuitPython folks over on the Adafruit Circuitpython Forums (https://forums.adafruit.com/viewforum.php?f=60) or Discord (adafruit)

1 Like

this whole time we had a sd card issue🤣

@RetiredWizard
buttonB = digitalio.DigitalInOut(board.GP6)
buttonB.direction = digitalio.Direction.INPUT
Traceback (most recent call last):
File “”, line 1, in
ValueError: GP6 in use

I don’t think the Pico uses GP6 for anything so I’m guessing it was grabbed by something you ran before this script. If you don’t execute a buttonB.deinit() you can’t redefine a new buttonB until the board resets (Ctrl-D or powercycle).

i only have code.py

# Imports
import audiobusio
from analogio import AnalogIn
import board
import digitalio
import adafruit_sdcard
import bitbangio
import storage
import time
import os
from audiomp3 import MP3Decoder
from audiocore import WaveFile
# End of Imports
# Init SD Card
spi = bitbangio.SPI(board.GP5,board.GP18,board.GP19)
cs = digitalio.DigitalInOut(board.GP22)
sd = adafruit_sdcard.SDCard(spi,cs)
vfs = storage.VfsFat(sd)
storage.mount(vfs, "/sd")
# End of init SD Card
# Setup LED
led = digitalio.DigitalInOut(board.LED)
led.direction = digitalio.Direction.OUTPUT
# End Of LED Setup
analog_in = AnalogIn(board.VOLTAGE_MONITOR)
a = audiobusio.I2SOut(board.GP27, board.GP28, board.GP26)
mp3 = open("low.mp3", "rb")
lowd = MP3Decoder(mp3)
wave_file = open("/sd/music/A circus.mp3", "rb")
wave = MP3Decoder(wave_file)
# Buttons Setup
buttonA = digitalio.DigitalInOut(board.GP0)
buttonA.direction = digitalio.Direction.INPUT
buttonC = digitalio.DigitalInOut(board.GP11)
buttonC.direction = digitalio.Direction.INPUT
# End Of Buttons Setup

current = 0
songs = len(os.listdir('/sd/music'))
songslist = os.listdir('/sd/music')

def get_voltage(pin):
    return (pin.value * 3.3) / 65536

paused = False
a.play(wave)
while True:
    if buttonA.value:
        if not a.paused and paused == False:
            a.pause()
            paused = True
            time.sleep(0)
        else:
            paused = False
            a.resume()
            time.sleep(0)
    if(get_voltage(analog_in) <= .5):
            if(led.value == True):
                a.play(lowd)
            led.value = False
    else:
        led.value = True