Skip to content

Instantly share code, notes, and snippets.

@ak1211

ak1211/main.py

Last active Jun 16, 2020
Embed
What would you like to do?
赤外線リモコン信号取得用 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
You can’t perform that action at this time.