Adafruit_Learning_System_Gu.../Adafruit_pIRKey/code.py
2022-02-18 13:50:39 -05:00

21 lines
609 B
Python

# SPDX-FileCopyrightText: 2018 Limor Fried for Adafruit Industries
#
# SPDX-License-Identifier: MIT
# Simple IR remote listener example
# Good for basic testing!
import pulseio
import board
import adafruit_dotstar
import adafruit_irremote
led = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1)
decoder = adafruit_irremote.GenericDecode()
pulsein = pulseio.PulseIn(board.REMOTEIN, maxlen=200, idle_state=True)
while True:
led[0] = (0, 0, 0) # LED off
pulses = decoder.read_pulses(pulsein)
led[0] = (0, 0, 100) # flash blue
print("\tHeard", len(pulses), "Pulses:", pulses)