Skip to content

Instantly share code, notes, and snippets.

@ak1211
Last active June 16, 2020 04:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ak1211/99e3c5dee1b89fb8d9a024ad171a6483 to your computer and use it in GitHub Desktop.
Save ak1211/99e3c5dee1b89fb8d9a024ad171a6483 to your computer and use it in GitHub Desktop.
赤外線リモコン信号取得用 circuit python プログラム
# https://ak1211.com/7586 (main.py)
# Copyright 2020 Akihiro Yamamoto
# Licensed under the Apache License, Version 2.0
import time
import board
import pulseio
from digitalio import DigitalInOut, Direction
# IRM
pulses = pulseio.PulseIn(board.D0, maxlen=2000, idle_state=True)
led = DigitalInOut(board.D13)
led.direction = Direction.OUTPUT
toggle = True
while True:
if (len(pulses) > 10):
pulses.pause()
output = '{"name":['
for i in range(len(pulses)):
output = output + "{},".format(pulses[i])
output = output[:-1] + "]}"
print(output)
pulses.resume()
pulses.clear()
led.value = toggle;
toggle = not toggle
time.sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment