code.py
 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)