Robert_dev
Robert_dev

Reputation: 19

How to fix pulseio module error in circuitpython on raspberry pi Pico?

Hello i use a raspberry pi Pico with RP2-80 20/34 P64M15.00 TTT chip with circuitpython 7.3.1 programing language and when i try to use pulseio module to capture a signal from a IR sensor i get that error,how can i fix this?

This is my code:

import board
import pulseio
import array

while True:
   ir_read=pulseio.PulseIn(board.GP7,maxlen=100,idle_state=True)
   command_on=array.array('H',[ir_read[x] for x in range(len(ir_read))])
   print(command_on)

This is the error:

Traceback (most recent call last):
  File "<stdin>", line 6, in <module>
ValueError: GP7 in use

Upvotes: 1

Views: 635

Answers (1)

Robert_dev
Robert_dev

Reputation: 19

I figured out what the problem was, it was just my mistake :))

I hope this can help someone:

import board
import pulseio
import adafruit_irremote

pulses = pulseio.PulseIn(board.GP3, maxlen=200, idle_state=True)
decoder = adafruit_irremote.GenericDecode()
pulses.clear()
pulses.resume()
while True:
   detected = decoder.read_pulses(pulses)
   print(f'got a pulse... {detected}')

Upvotes: 0

Related Questions