/ Adafruit_pIRKey / code.py
code.py
 1  # SPDX-FileCopyrightText: 2018 Limor Fried for Adafruit Industries
 2  #
 3  # SPDX-License-Identifier: MIT
 4  
 5  # Simple IR remote listener example
 6  # Good for basic testing!
 7  
 8  import pulseio
 9  import board
10  import adafruit_dotstar
11  import adafruit_irremote
12  
13  led = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1)
14  decoder = adafruit_irremote.GenericDecode()
15  pulsein = pulseio.PulseIn(board.REMOTEIN, maxlen=200, idle_state=True)
16  
17  while True:
18      led[0] = (0, 0, 0)   # LED off
19      pulses = decoder.read_pulses(pulsein)
20      led[0] = (0, 0, 100) # flash blue
21      print("\tHeard", len(pulses), "Pulses:", pulses)