TLDR; I have a Teensy LC and can receive IR, or transmit IR. But if I try them together, the receive only works once.
So I bought a couple of Teensy LCs, a couple of IR transmitters, and IR receivers. I'd like to wirelessly send IR from one to the other and vise versa but the first step is to just get IR transmitting and receiving on one Teensy. So I started with the code posted here, and combined the transmit and receive into a single project in the hopes that I can just make a repeater as a test where it looks for new messages and retransmits them. Here is my code:
The receive is wired to pin 6, and transmit is on pin 16. Both transmit and receive are powered by the 3.3V of the Teensy for now but was unsure if the 5V should be used. The kit I bought mentioned Arduino with little more documentation so I assume it is 5V tolerant.
So my problem is the decode only works once, if I am sending the received message out. If I just receive (by commenting out the irsend.sendNEC) then my receive works and I get the NEC message and the number of bits over serial, over and over. If I enable the send (the way the code is now) then the first time it sees a message it will receive it, put it on serial, and transmit it. But then decode will always return false.
Is the Teensy LC able to transmit and receive at once? Is there an issue with the library where a timer is used in sending that screws up the receive? I added code transmit data over serial periodically and the Teensy always sends data so I assume it isn't resetting. This is with Arduino 1.8.1 and Teensyduino 1.35, and the IRremote library it comes with. Any help is appreciated, thanks.
So I bought a couple of Teensy LCs, a couple of IR transmitters, and IR receivers. I'd like to wirelessly send IR from one to the other and vise versa but the first step is to just get IR transmitting and receiving on one Teensy. So I started with the code posted here, and combined the transmit and receive into a single project in the hopes that I can just make a repeater as a test where it looks for new messages and retransmits them. Here is my code:
Code:
#include <IRremote.h>
const int RECV_PIN = 6;
IRrecv irrecv(RECV_PIN);
IRsend irsend;
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
irrecv.blink13(true);
}
void loop() {
if (irrecv.decode(&results)) {
if (results.decode_type == NEC) {
Serial.print("NEC: ");
//irsend.sendNEC(results.value, results.bits);
} else if (results.decode_type == SONY) {
Serial.print("SONY: ");
irsend.sendSony(results.value, results.bits);
} else if (results.decode_type == RC5) {
Serial.print("RC5: ");
irsend.sendRC5(results.value, results.bits);
} else if (results.decode_type == RC6) {
Serial.print("RC6: ");
irsend.sendRC6(results.value, results.bits);
} else if (results.decode_type == UNKNOWN) {
Serial.print("UNKNOWN: ");
}
Serial.println(results.value, HEX);
Serial.println(results.bits, DEC);
irrecv.resume(); // Receive the next value
Serial.print("1");
irsend.sendNEC(results.value, results.bits);
Serial.print("2");
delay(100);
Serial.print("3");
}
}
The receive is wired to pin 6, and transmit is on pin 16. Both transmit and receive are powered by the 3.3V of the Teensy for now but was unsure if the 5V should be used. The kit I bought mentioned Arduino with little more documentation so I assume it is 5V tolerant.
So my problem is the decode only works once, if I am sending the received message out. If I just receive (by commenting out the irsend.sendNEC) then my receive works and I get the NEC message and the number of bits over serial, over and over. If I enable the send (the way the code is now) then the first time it sees a message it will receive it, put it on serial, and transmit it. But then decode will always return false.
Is the Teensy LC able to transmit and receive at once? Is there an issue with the library where a timer is used in sending that screws up the receive? I added code transmit data over serial periodically and the Teensy always sends data so I assume it isn't resetting. This is with Arduino 1.8.1 and Teensyduino 1.35, and the IRremote library it comes with. Any help is appreciated, thanks.
Last edited: