I have been trying all day and have read many examples, this being the nearest: Similar issue which I can't get to work..
The purpose is to blast sequential codes at a Kenwood device to see what it responds to. The codes are made up of an address (9D62) the function ( 0-FF) and the inverse of the function as a checksum. I can get the string I want from the serial monitor but not delivered to the IR LED.
I would be grateful for any help you could offer to see what I am doing wrong please.
/*
Sequential code blaster for Kenwood.
Delay used because it doesn't matter in this application.
*/
#include <IRremote.h>
IRsend irsend;
#define IR_SEND_PIN 9
const byte val1 = 0;
const byte val2 = 0;
byte val3 = 0;
byte val4 = 0;
void setup()
{
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
void loop()
{
struct MyData {
const byte val1;
const byte val2;
byte val3;
byte val4;
};
for (byte i = 0; i < 255; i++) {
byte inv = (~i);
byte pos = (i);
struct MyData data ;
data.val1 = 0x9D;
data.val2 = 0x62;
data.val3 = pos;
data.val4 = inv;
// irsend.sendNEC((0x9D626897), 32);// this Tx is correct
irsend.sendNEC((&data, sizeof(struct MyData), 32));// Kenwood IR
//A typical working code looks like: 0x9D626897
//(constant address 9D62) (code) (inverse code)
Serial.print(((byte)add), HEX),
Serial.print(((byte)add2), HEX),
Serial.print((byte)(i), HEX),
Serial.print(((byte)inv), HEX),
Serial.println(" ");
delay(1000);
}
delay(5000); //restart delay