Skip to content

I tried running the code with Circuitpython in a Pi Pico W and it doesn't work #60

Closed
@mr-pepe69

Description

@mr-pepe69

the code i used instead was:

import pulseio
import board
import adafruit_irremote
pulsein = pulseio.PulseIn(board.GP0, maxlen=120, idle_state=True)
decoder = adafruit_irremote.GenericDecode()
but1 = "(255, 0, 93, 162)"
while True:
    pulses = decoder.read_pulses(pulsein)
    print("Heard", len(pulses), "Pulses:", pulses) 
    try:

        code = decoder.decode_bits(pulses)
        codestr = str(code)
        print("Decoded:", code)
        if codestr == but1:
            print('uwu')
        else:
            print('no')
        
    except adafruit_irremote.FailedToDecode:  # unusual short code!
        print("NEC repeat!")
        continue
    except adafruit_irremote.IRDecodeException as e:     # failed to decode
        print("Failed to decodeunu: ", e.args)
        continue
    print("----------------------------")

i trully don't understand why changing the except made it to work (i also added a couple things to make it usefull. not good code, but does the trick) i'm kinda new to this, so if there is something needed just tell me. (i read the except from the source code and i got the example from there too.)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions