joshsstuff
New Member
Hello Gang!
I am trying to clone the IR signal of consumer electronics to give IR control to my Arduino.
(I wish to give the Arduino the ability to turn on and off a TV)
This seems simple enough, and there are several tutorials online, so, easy, right?
I've found several examples of how to copy the IR signal into the Serial Monitor my problem is re-transmitting them with my IR Led from my arduino.
Demo Hardware:
My breadboard example:
I'm using an detector to collect the IR signals, and a 940nm IR LED to transmit.
Most of the tutorials I find on the internet are based on outdated IR Libraries.
(I don't mind this, as long as I can get them to work)
After failing to transmit the captured codes from my IR Led I tired the examples from the new IRlib2 library.
I've tried the "rawRecv" example sketch and successfully captured the timing data.
I get this code from my samsung remote:
Here is the 'rawSend' example sketch:
Hardware
I'm using a 940nm IR LED driven by a 2222a BJT.
I used the diagram from a tutorial that used a 4.6K resistor on the base.
(should I have a current limiter for the IR LED?)
Here is my question:
After I paste the timing code into "rawSend" How do I code the LED to turn on and off with the appropriate timing?
I've tried many tutorials I found online, but perhaps because they use a different library, I'm not having success.
I've tried examples like these:
Code: https://howtomechatronics.com/tutor...ronics-with-a-tv-remote-arduino-ir-tutorial/
https://howtomechatronics.com/tutor...tronics-with-a-tv-remote-arduino-ir-tutorial/
https://www.instructables.com/id/Arduino-Infrared-Remote-tutorial/
Using IR commands to control consumer electronics is something I'd like to use a lot once I figure it out.
Any tips would be greatly appreciated!
Thanks!
I am trying to clone the IR signal of consumer electronics to give IR control to my Arduino.
(I wish to give the Arduino the ability to turn on and off a TV)
This seems simple enough, and there are several tutorials online, so, easy, right?
I've found several examples of how to copy the IR signal into the Serial Monitor my problem is re-transmitting them with my IR Led from my arduino.
Demo Hardware:
My breadboard example:
I'm using an detector to collect the IR signals, and a 940nm IR LED to transmit.
Most of the tutorials I find on the internet are based on outdated IR Libraries.
(I don't mind this, as long as I can get them to work)
After failing to transmit the captured codes from my IR Led I tired the examples from the new IRlib2 library.
I've tried the "rawRecv" example sketch and successfully captured the timing data.
Code:
/* rawR&cv.ino Example sketch for IRLib2
* Illustrate how to capture raw timing values for an unknow protocol.
* You will capture a signal using this sketch. It will output data the
* serial monitor that you can cut and paste into the "rawSend.ino"
* sketch.
*/
// Recommend only use IRLibRecvPCI or IRLibRecvLoop for best results
#include <IRLibRecvPCI.h>
IRrecvPCI myReceiver(2);//pin number for the receiver
void setup() {
Serial.begin(9600);
delay(2000); while (!Serial); //delay for Leonardo
myReceiver.enableIRIn(); // Start the receiver
Serial.println(F("Ready to receive IR signals"));
}
void loop() {
//Continue looping until you get a complete signal received
if (myReceiver.getResults()) {
Serial.println(F("Do a cut-and-paste of the following lines into the "));
Serial.println(F("designated location in rawSend.ino"));
Serial.print(F("\n#define RAW_DATA_LEN "));
Serial.println(recvGlobal.recvLength,DEC);
Serial.print(F("uint16_t rawData[RAW_DATA_LEN]={\n\t"));
for(bufIndex_t i=1;i<recvGlobal.recvLength;i++) {
Serial.print(recvGlobal.recvBuffer[i],DEC);
Serial.print(F(", "));
if( (i % 8)==0) Serial.print(F("\n\t"));
}
Serial.println(F("1000};"));//Add arbitrary trailing space
myReceiver.enableIRIn(); //Restart receiver
I get this code from my samsung remote:
Code:
Do a cut-and-paste of the following lines into the
designated location in rawSend.ino
#define RAW_DATA_LEN 68
uint16_t rawData[RAW_DATA_LEN]={
4530, 4514, 562, 1686, 562, 1682, 566, 1682,
562, 590, 534, 590, 534, 590, 534, 590,
534, 590, 534, 1686, 558, 1686, 562, 1686,
562, 590, 534, 590, 534, 590, 530, 594,
530, 594, 530, 590, 534, 1686, 562, 590,
534, 590, 534, 590, 534, 590, 534, 594,
526, 594, 530, 1686, 562, 590, 534, 1690,
558, 1682, 562, 1686, 562, 1686, 562, 1686,
562, 1682, 562, 1000};
Here is the 'rawSend' example sketch:
Code:
/* rawSend.ino Example sketch for IRLib2
* Illustrates how to send a code Using raw timings which were captured
* from the "rawRecv.ino" sample sketch. Load that sketch and
* capture the values. They will print in the serial monitor. Then you
* cut and paste that output into the appropriate section below.
*/
#include <IRLibSendBase.h> //We need the base code
#include <IRLib_HashRaw.h> //Only use raw sender
IRsendRaw mySender;
void setup() {
Serial.begin(9600);
delay(2000); while (!Serial); //delay for Leonardo
Serial.println(F("Every time you press a key is a serial monitor we will send."));
}
/* Cut and paste the output from "rawRecv.ino" below here. It will
* consist of a #define RAW_DATA_LEN statement and an array definition
* beginning with "uint16_t rawData[RAW_DATA_LEN]= {…" and concludes
* with "…,1000};"
*/
/*
* Cut-and-paste into the area above.
*/
void loop() {
if (Serial.read() != -1) {
//send a code every time a character is received from the
// serial port. You could modify this sketch to send when you
// push a button connected to an digital input pin.
mySender.send(rawData,RAW_DATA_LEN,36);//Pass the buffer,length, optionally frequency
Serial.println(F("Sent signal."));
}
}
Hardware
I'm using a 940nm IR LED driven by a 2222a BJT.
I used the diagram from a tutorial that used a 4.6K resistor on the base.
(should I have a current limiter for the IR LED?)
Here is my question:
After I paste the timing code into "rawSend" How do I code the LED to turn on and off with the appropriate timing?
I've tried many tutorials I found online, but perhaps because they use a different library, I'm not having success.
I've tried examples like these:
Code: https://howtomechatronics.com/tutor...ronics-with-a-tv-remote-arduino-ir-tutorial/
https://howtomechatronics.com/tutor...tronics-with-a-tv-remote-arduino-ir-tutorial/
https://www.instructables.com/id/Arduino-Infrared-Remote-tutorial/
Using IR commands to control consumer electronics is something I'd like to use a lot once I figure it out.
Any tips would be greatly appreciated!
Thanks!
Last edited by a moderator: