Created
January 19, 2018 18:28
-
-
Save jedgarpark/e3c50c34eac2ca1dc80ffc9ca859d8e8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# IR reader | |
import board | |
import pulseio | |
import adafruit_irremote | |
IR_PIN = board.D10 # Pin connected to IR receiver on Feather M0 Express | |
# _____ | |
# | | | |
# |_____| | |
# | | | | |
# | | | | |
# | |
# 10 G V+ | |
import pulseio | |
import board | |
import adafruit_irremote | |
pulsein = pulseio.PulseIn(board.D10, maxlen=120, idle_state=True) | |
decoder = adafruit_irremote.GenericDecode() | |
# size must match what you are decoding! for NEC use 4 | |
received_code = bytearray(4) | |
while True: | |
pulses = decoder.read_pulses(pulsein) | |
print("Heard", len(pulses), "Pulses:", pulses) | |
try: | |
code = decoder.decode_bits(pulses, debug=False) | |
print("Decoded:", code) | |
except adafruit_irremote.IRNECRepeatException: # unusual short code! | |
print("NEC repeat!") | |
except adafruit_irremote.IRDecodeException as e: # failed to decode | |
print("Failed to decode: ", e.args) | |
print("----------------------------") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment