Lost in the IRremote library.... Want a simple send command for the Leonardo/Attiny85

I analysed a hard to find IR remote from a drum computer, and wrote some code to write down the outcoming data and managed to retreive all keycodes and the device code. Also saw the mirroring of the command byte as 4rd byte of the pulse. No idea it was a NEC protocol yet.
Then I found background info. Trying to send a signal was harder, so I thought lets use a library. I found the Teensy explanation to be the cleanest:
https://www.pjrc.com/teensy/td_libs_IRremote.html
Imo the way to document things. not blow things out of proportion like the current github repo documentation. The Teensy sample does not show how to send a 32bit code though with my structure.

So I can't get this to example to work, I started with a visible blue LED to check if light is produced.
Protocol is NEC 38kHz
This is the device address in the order of light pulses, it is send first:
B00000001,B00110110
you could write it as
word deviceCode=0x0136;
And this is a sample command (it should be send twice, second time inverted)
byte command=B01111000, // down
in hex it would be 0x78

Can someone give me the simplest bit of code that just sends this command in setup for example. Please mention the required IR LED pin for your example if I use a Leonardo or a Attiny85. Please use the variables deviceCode and command in the example. If the format is not usuable, then explain how to reformat. I don't want to include all codes as full 32bit chunk, as that is a waste of memory.

DronebotWorkshop demonstrates IRxmit in his web site:

The code:

/*
  IR Transmitter Demonstration 1
  IR-Xmit-Demo1.ino
  Control TV using IR Library
  IR LED must use Pin #3
  DroneBot Workshop 2017
  http://dronebotworkshop.com
*/
 
// Include IR Remote Library by Ken Shirriff
 
#include <IRremote.h>
 
// Define switch pin
const int switchPin = 7;
 
// Define a variable for the button state
int buttonState = 0;
 
// Create IR Send Object
IRsend irsend;
 
void setup()
{
  // Set Switch pin as Input
  pinMode(switchPin, INPUT);
}
 
void loop() {
  
  // Set button state depending upon switch position
  buttonState = digitalRead(switchPin);
  
  // If button is pressed send power code command
   if (buttonState == HIGH) {
    irsend.sendNEC(0xFEA857, 32); // TV power code
  }
      
    // Add a small delay before repeating
    delay(200);
 
} 

Thanks,
The code looks like its 24 bits. Is the device missing leading zeros? So basically 0x00FEA857.? I see the 57 is the inversion of A8, so thats the command pair.

I ran into another problem. The Leonardo seems to use pin 13 for transmit IR, yet it is the incoming serial LED as well. Can I use another pin and how is that done? I don't want the IR led to visualise serial data.

"drum computer"?

image

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.