Hi.
I'm trying to control my TV (it's a BLAUPUNKT) using the arduino and an infrared led.
I am using the IRremote.h library by shirriff for this.
I already read the button codes from the TV remote, and wrote them to notepad. For that, I used the following code:
#include <IRremote.h>
const int RECV_PIN = 12;
IRrecv irrecv(RECV_PIN);
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: ");
} else if (results.decode_type == SONY) {
Serial.print("SONY: ");
} else if (results.decode_type == RC5) {
Serial.print("RC5: ");
} else if (results.decode_type == RC6) {
Serial.print("RC6: ");
} else if (results.decode_type == UNKNOWN) {
Serial.print("UNKNOWN: ");
} else {
Serial.print("wtf: ");
}
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
}
}
And the wiring was just directly from the IR sensor pins to the pins on the arduino (VCC to 5V, GND to GND, OUT to 12 digital input). The IR sensor I'm using is VS1838B, datasheet here: https://www.elecrow.com/download/Infrared%20receiver%20vs1838b.pdf (I also don't understand chinese, but it says the pinout of the sensor).
Now, when I try to send one of the codes (already tried a few different button codes), using the following code:
/*
An IR LED must be connected to Arduino PWM pin 3.
*/
#include <IRremote.h>
IRsend irsend;
void setup()
{
}
void loop() {
irsend.sendNEC(0xFEFA05, 24);
delay(1000);
irsend.sendNEC(0xFEFA05, 24);
delay(40);
irsend.sendNEC(0xFEFA05, 24);
delay(1000);
}
and the wiring: Arduino PWM pin 3 (output from the library) to 220 ohm resistor, then from that resistor to infrared led positive, then from the infrared led negative to arduino GND. Did how the library author says here under the "Hardware Setup" subtitle: A Multi-Protocol Infrared Remote Library for the Arduino
The led blinks every second when I look at it using the phone camera, and its brightness is very similar to the TV remote.
But when I turn the IR led to the TV like a remote, even if I put it close to the TV IR sensor, it won't react.
Any ideas what could be wrong?
Some more info:
Arduino is the arduino UNO;
I don't have more arduinos, so can't test send and receive, unless it can be done on the same arduino, sending and receiving at the same time *.
If I missed some useful info, please tell me.
Thank you.
- I already tried send and receive from the same arduino, but I can't get it to work properly. I tried this code:
/*
An IR LED must be connected to Arduino PWM pin 3.
*/
#include <IRremote.h>
const int RECV_PIN = 12;
IRsend irsend;
IRrecv irrecv(RECV_PIN);
decode_results results;
unsigned long previousMillis = 0;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
irrecv.blink13(true);
}
void loop() {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= 1000) {
previousMillis = currentMillis;
irsend.sendNEC(0xFE0AF5, 24);
irrecv.enableIRIn();
}
if (irrecv.decode(&results)) {
if (results.decode_type == NEC) {
Serial.print("NEC: ");
} else if (results.decode_type == SONY) {
Serial.print("SONY: ");
} else if (results.decode_type == RC5) {
Serial.print("RC5: ");
} else if (results.decode_type == RC6) {
Serial.print("RC6: ");
} else if (results.decode_type == UNKNOWN) {
Serial.print("UNKNOWN: ");
}
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
}
}
It should every second send the signal and read for signals all the time. But I can't get it to read itself:
Trying to read from itself:
vid1.mp4 (sorry, the forum says error when I attach the videos)
The feedback on led 13 is weak.
Trying to read from the TV remote:
vid2.mp4
Much stronger feedback, and the library can even recognise it and send to the serial.
Seems to me that it is only receiving the final part of the signal sent by itself.
I don't know what to try next. Any ideas?
PS: this is a nice doc about the library from which I based some of my code: IRremote Library, Send & Receive Infrared Remote Control