Skip to content

Commit 2c74a5d

Browse files
authored
Merge pull request #2331 from adafruit/ir_example
adding basic IR CP example
2 parents 59ae4b1 + a10d50f commit 2c74a5d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

STEMMA_IR_LED_Emitter/code.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# SPDX-FileCopyrightText: 2022 Liz Clark for Adafruit Industries
2+
# SPDX-License-Identifier: MIT
3+
# Based on irremote_transmit.py for CPX by ladyada
4+
5+
import time
6+
import pulseio
7+
import board
8+
import adafruit_irremote
9+
10+
# Create a 'PulseOut' to send infrared signals on the IR transmitter @ 38KHz
11+
pulseout = pulseio.PulseOut(board.D5, frequency=38000, duty_cycle=2**15)
12+
# Create an encoder that will take numbers and turn them into NEC IR pulses
13+
emitter = adafruit_irremote.GenericTransmit(
14+
header=[9500, 4500], one=[550, 550], zero=[550, 1700], trail=0
15+
)
16+
17+
# count variable
18+
count = 0
19+
20+
while True:
21+
# send IR pulse
22+
emitter.transmit(pulseout, [255, 2, 255, 0])
23+
# increase count
24+
count += 1
25+
# print to REPL
26+
print("IR signal sent %d times!" % count)
27+
# two second delay
28+
time.sleep(2)

0 commit comments

Comments
 (0)