I am testing IR LED as a sender pin3, and IR module as receiver pin2, and used codes as below, question are:
1. the receive data seems lot of noise;
2. I checked the send code mostly like this:
Code: Select all
mySender.send(rawData, RAW_DATA_LEN, 2)
Code: Select all
mySender.send(SONY,0xa8bca, 20);
Code: Select all
IrSender.sendNEC(0x0102, 0x34, true, 0);
Code: Select all
mySender.send(xyz);
xyz = any number or characters.
Thanks for help.
Adam
Sender code:
Code: Select all
#include <IRLibSendBase.h> //We need the base code
#include <IRLib_HashRaw.h> //Only use raw sender
IRsendRaw mySender;
#define RAW_DATA_LEN 2
uint16_t rawData[RAW_DATA_LEN] = { 2406, 1000};
int button = 4;
void setup() {
Serial.begin(9600);
delay(2000); while (!Serial); //delay for Leonardo
pinMode(button, INPUT);
Serial.println(F("Every time you press a key is a serial monitor we will send."));
}
void loop() {
if (digitalRead(button) == HIGH) {
for (int i = 0; i < 3; i++)
{
mySender.send(rawData, RAW_DATA_LEN, 2); //Pass the buffer,length, optionally frequency
Serial.println(F("Sent signal."));
}
}
}
Code: Select all
#include <IRLibRecvPCI.h>
IRrecvPCI myReceiver(2);//pin number for the receiver
void setup() {
Serial.begin(115200);
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()) {
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
}
}