-
Notifications
You must be signed in to change notification settings - Fork 33
Add tx example #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tx example #14
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"""IR transmit example using Circuit Playground Express""" | ||
import time | ||
import adafruit_irremote | ||
import pulseio | ||
import board | ||
import digitalio | ||
|
||
# Create a button object to trigger IR transmit | ||
button = digitalio.DigitalInOut(board.D4) | ||
button.direction = digitalio.Direction.INPUT | ||
button.pull = digitalio.Pull.DOWN | ||
|
||
# Create a 'pulseio' output, to send infrared signals on the IR transmitter @ 38KHz | ||
pwm = pulseio.PWMOut(board.IR_TX, frequency=38000, duty_cycle=2 ** 15) | ||
pulseout = pulseio.PulseOut(pwm) | ||
# Create an encoder that will take numbers and turn them into NEC IR pulses | ||
encoder = adafruit_irremote.GenericTransmit(header=[9500, 4500], one=[550, 550], | ||
zero=[550, 1700], trail=0) | ||
|
||
while True: | ||
if button.value: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see comment above about using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good! Adding now. |
||
encoder.transmit(pulseout, [255, 2, 255, 0]) | ||
time.sleep(0.2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be
digitalio.Pull.UP
to match essentials guide, etc? would require changing the conditional in the loopThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The buttons are backwards on the CPX. So either this or the loop will be backwards for CPX or an external button. We'll leave it as CPX for now and consider changing it if we receive a bunch of feedback.