# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
"""IR transmit example for Samsung TV using Circuit Playground Express"""
# pylint: disable-msg=no-member
import time
import pulseio
import board
import digitalio
import adafruit_irremote
# Create a button object to trigger IR transmit
button = digitalio.DigitalInOut(board.GP0)
button.direction = digitalio.Direction.INPUT
button.pull = digitalio.Pull.DOWN
pulseout = pulseio.PulseOut(board.GP1, frequency=38000, duty_cycle=2**15)
encoder = adafruit_irremote.GenericTransmit(
header=[9500, 4500], one=[550, 550], zero=[550, 1700], trail=0
)
while True:
if button.value:
print("IR signal sent!")
encoder.transmit(pulseout, [31, 31, 152, 103])
time.sleep(0.2)
Currently using the code above to attempt to transmit a simple power button press with the press of 'button'.
It runs the while loop without error, but nothing happens. I press the button and see the print statement, but nothing else. Where can I find the integers header, one, zero, and trail based on my TV. Documentation for the parameters is as follows:
header (int) – The length of header in microseconds
one (int) – The length of a one in microseconds
zero (int) – The length of a zero in microseconds
trail (int) – The length of the trail in microseconds, set to None to disable
I wanted to control a Sony camera and I looked at the Sony IRLib2 code for how to generate those for cpx-ir-shutter-remote.py. There's Samsung code in IRLib2 too which should be useful as a basis for your code.