using irRemote from other library
hi all,
background of project:
i want control lego power function devices arduino via infrared, want replace both, sender , receiver, arduino , custom protocol allow more accurate steering , have more outputs available.
for better re-usability thought of creating receiver library doing protocol handling, etc. implementing library irremote doing ir part.
but here comes problem, not understand: if call irremote library, garbage result irremote. if call same code ino results fine.
so, can explain me problem is:
code working (using irremote directly ino)
ino file
here following output if press
nec: ffa25d
now comes problem:
code faulty using irremote other library
ino file
library cpp
here, if press standby button on remote again, allways random values:
unknown: e9e70e8d
unknown: cf51c16e
unknown: e1886d7f
unknown: 4bcf0c40
so, problem here? can explain behavior?
thanks, butch
background of project:
i want control lego power function devices arduino via infrared, want replace both, sender , receiver, arduino , custom protocol allow more accurate steering , have more outputs available.
for better re-usability thought of creating receiver library doing protocol handling, etc. implementing library irremote doing ir part.
but here comes problem, not understand: if call irremote library, garbage result irremote. if call same code ino results fine.
so, can explain me problem is:
code working (using irremote directly ino)
ino file
code: [select]
#include "arduino.h"
#include <irremote.h>
const int recv_pin = a5;
irrecv irrecv(recv_pin);
decode_results results;
void setup()
{
serial.begin(9600);
irrecv.enableirin(); // start receiver
irrecv.blink13(true);
serial.println ("starting direct sketch");
}
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: ");
}
serial.println(results.value, hex);
irrecv.resume(); // receive next value
}
}
here following output if press
nec: ffa25d
now comes problem:
code faulty using irremote other library
ino file
code: [select]
#include "arduino.h"
#include "receiverlibtest.h"
//the setup function called once @ startup of sketch
receiverlibtest irreceiver;
void setup()
{
// add initialization code here
serial.begin(9600);
serial.println("starting lib sketch");
}
// loop function called in endless loop
void loop()
{
irreceiver.processdata();
}
library cpp
code: [select]
// not remove include below
#include "receiverlibtest.h"
#include "irremote.h"
#define ir_receive_pin a5
irrecv irrecv(ir_receive_pin);
decode_results results;
receiverlibtest::receiverlibtest()
{
// instanciate infrared library on given pin
// start ir receiver
irrecv.enableirin();
}
void receiverlibtest::processdata()
{
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 next value
}
}
here, if press standby button on remote again, allways random values:
unknown: e9e70e8d
unknown: cf51c16e
unknown: e1886d7f
unknown: 4bcf0c40
so, problem here? can explain behavior?
thanks, butch
maybe there device mismatch.
this may not might interesting:
nec library
http://forum.arduino.cc/index.php?topic=317625.0
.
this may not might interesting:
nec library
http://forum.arduino.cc/index.php?topic=317625.0
.
Arduino Forum > Using Arduino > Programming Questions > using irRemote from other library
arduino
Comments
Post a Comment