Two PWM out IR Remote Sending on Circuit Playground Bluefruit

Play with it! Please tell us which board you're using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Momtoast
 
Posts: 9
Joined: Thu Sep 08, 2022 11:50 pm

Two PWM out IR Remote Sending on Circuit Playground Bluefruit

Post by Momtoast »

Greetings all!

I am trying to get my CPB to send out the same irremote signal through two different pins. It does show on the pinout that both TX and A6 are PWM out. TX is working fine, but A6/RX is not firing correctly. It only does a brief bit of the pulse out and stops short. I have included the code below. The plan is to attached the CPB to a glove, and have an IR LED on the back of the hand and one on the palm, so the remote signal can be sent no matter which position the hand is in.

Code: Select all

import time
import pulseio
import busio
import board
import adafruit_irremote
from adafruit_circuitplayground import cp

# Create a 'PulseOut' to send infrared signals on the IR transmitter @ 38KHz
pulseout = pulseio.PulseOut(board.TX, frequency=38000, duty_cycle=2**15)
pulseout2 = pulseio.PulseOut(board.RX, frequency=38000, duty_cycle=2**15)
# 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
)
encoder2 = adafruit_irremote.GenericTransmit(
    header=[9500, 4500], one=[550, 550], zero=[550, 1700], trail=0
)

RED = (255, 0, 0)
YELLOW = (255, 150, 0)
GREEN = (0, 255, 0)
CYAN = (0, 255, 255)
BLUE = (0, 0, 255)
PURPLE = (180, 0, 255)
WHITE = (255, 255, 255)
OFF = (0, 0, 0)

heals = (255, 0, 93, 162)

cp.pixels.brightness = 0.3

def color_chase(color, wait):
    for i in range(10):
        cp.pixels[i] = color
        time.sleep(wait)
    time.sleep(0.02)

def flash_hit(color):
    color_chase(RED, .02)
    color_chase(OFF, .02)
    color_chase(color, .02)
    cp.play_file("examples_dip.wav")

cp.pixels.fill(BLUE)

while True:
    x, y, z = cp.acceleration
    if cp.shake(shake_threshold=11):
        if z < -5.0 and (y < 5.0 or y > -5.0):
            encoder.transmit(pulseout, [255, 0, 93, 162])
            encoder2.transmit(pulseout2, [255, 0, 93, 162])
            flash_hit(GREEN)
            print(x, y, z)
            print(encoder.transmit(pulseout2, [255, 0, 93, 162]))
            time.sleep(0.2)
        elif y > 5.0:                         # palm facing away
            if x < -5.0:                      # tipped counterclockwise
                encoder.transmit(pulseout, [50, 2, 255, 50])
                encoder2.transmit(pulseout2, [50, 2, 255, 50])
                flash_hit(YELLOW)
                print(x, y, z)
                print(pulseout2)
                time.sleep(0.2)
            elif x > 5.0:                     # tipped clockwise
                encoder.transmit(pulseout, [255, 0, 93, 50])
                encoder2.transmit(pulseout2, [255, 0, 93, 50])
                flash_hit(WHITE)
                print(x, y, z)
                print(pulseout2)
                time.sleep(0.2)
            else:                             # straight up
                encoder.transmit(pulseout, [200, 0, 93, 50])
                encoder2.transmit(pulseout2, [200, 0, 93, 50])
                flash_hit(BLUE)
                print(x, y, z)
                print(pulseout2)
                time.sleep(0.2)
        elif y < -5.0:                        # palm facing toward (hand down)
            encoder.transmit(pulseout, [200, 0, 93, 50])
            encoder2.transmit(pulseout2, [200, 0, 93, 50])
            flash_hit(PURPLE)
            print(x, y, z)
            print(pulseout2)
            time.sleep(0.2) 

User avatar
Franklin97355
 
Posts: 23911
Joined: Mon Apr 21, 2008 2:33 pm

Re: Two PWM out IR Remote Sending on Circuit Playground Bluefruit

Post by Franklin97355 »

Can you try A5 instead? TX is HS and A6 is LS. Let me know if it makes a difference.

User avatar
Momtoast
 
Posts: 9
Joined: Thu Sep 08, 2022 11:50 pm

Re: Two PWM out IR Remote Sending on Circuit Playground Bluefruit

Post by Momtoast »

No, not working there either. I didn't think it would as the only two pins marked as useful for PWM were TX and RX they would be the only ones that could do it. I have tried all the other pins, same result.

I'm wondering if I can chain the LEDs instead? Or will that also throw off the signal?

User avatar
Franklin97355
 
Posts: 23911
Joined: Mon Apr 21, 2008 2:33 pm

Re: Two PWM out IR Remote Sending on Circuit Playground Bluefruit

Post by Franklin97355 »

OK, I'll ask but did you see the user manual, specifically page 21 and 22? https://www.infineon.com/dgdl/Infineon- ... 5721903ddd

User avatar
Momtoast
 
Posts: 9
Joined: Thu Sep 08, 2022 11:50 pm

Re: Two PWM out IR Remote Sending on Circuit Playground Bluefruit

Post by Momtoast »

Please feel free to talk to me like I don't know much. I'm not afraid to admit I'm fairly new to all this and still learning. Especially in regards to the math for power supply. I know enough to mostly figure out what pins can do what and how to do the programming (which is the stuff I'm more comfortable with).

The LEDs are the only things I'm adding to the board, but I am using the neopixels and accelerometer already attached. My test (not yet soldered) version with the two LEDs on one pin is working so far, using a 3AAA battery for power.

User avatar
adafruit2
 
Posts: 22148
Joined: Fri Mar 11, 2005 7:36 pm

Re: Two PWM out IR Remote Sending on Circuit Playground Bluefruit

Post by adafruit2 »

well, here's the question just because we wanna get your set up working - why do you need that? you want the signal to point in two directions? or you want them to send at different times?

User avatar
Momtoast
 
Posts: 9
Joined: Thu Sep 08, 2022 11:50 pm

Re: Two PWM out IR Remote Sending on Circuit Playground Bluefruit

Post by Momtoast »

I would like to have one on the palm of a glove and another on the back of the hand. They would fire at the same time and fire the same code.

It's going on a glove. It will fire a code when the wearer makes different gestures. I figured having only one led on one side of the hand wouldn't work for all the gestures. (The hand would block the signal if the led wasn't pointing at the target)

I haven't done a lot of solid testing as I'm hesitant to solder two to the board if they aren't going to fire properly at all.

User avatar
adafruit2
 
Posts: 22148
Joined: Fri Mar 11, 2005 7:36 pm

Re: Two PWM out IR Remote Sending on Circuit Playground Bluefruit

Post by adafruit2 »

how far do you need it to work? like distance/meters?

User avatar
Momtoast
 
Posts: 9
Joined: Thu Sep 08, 2022 11:50 pm

Re: Two PWM out IR Remote Sending on Circuit Playground Bluefruit

Post by Momtoast »

3 meters at the most, I would think. I've been getting around 2 meters with just one LED, so maybe that's wishful thinking. I'm working on a laser tag game where you can use either guns, magic wands, or the gloves to fire at a sensor on the other person. Across a room would be enough.

User avatar
Momtoast
 
Posts: 9
Joined: Thu Sep 08, 2022 11:50 pm

Re: Two PWM out IR Remote Sending on Circuit Playground Bluefruit

Post by Momtoast »

I think maybe I will try putting the IR LED in the space between the finger and thumb, so it can send a signal toward the target with the palm either up or down. Then I wouldn't need two.

User avatar
Franklin97355
 
Posts: 23911
Joined: Mon Apr 21, 2008 2:33 pm

Re: Two PWM out IR Remote Sending on Circuit Playground Bluefruit

Post by Franklin97355 »

Since it is on a glove have you considered wiring them together and sending both the same signal?

User avatar
Momtoast
 
Posts: 9
Joined: Thu Sep 08, 2022 11:50 pm

Re: Two PWM out IR Remote Sending on Circuit Playground Bluefruit

Post by Momtoast »

That's what I am going to try next. When I have some time to do some soldering again.

Locked
Please be positive and constructive with your questions and comments.

Return to “Circuit Playground Classic, Circuit Playground Express, Circuit Playground Bluefruit”