Last active
June 16, 2020 04:05
-
-
Save ak1211/99e3c5dee1b89fb8d9a024ad171a6483 to your computer and use it in GitHub Desktop.
赤外線リモコン信号取得用 circuit python プログラム
This file contains 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
# 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