I open this new subject to ask for advice, see if what I did is in good practices and if so, share this tiny sketch with others.
What I want to do is very simple (so sketch too) !
I would like to auto switch-on my Logitech audiokit Z5500 when I switch-on my Samsung LED TV (and switch it off when I switch off the TV), with one remote control (the TV's one) and without hacking the Z5500.
I detect the TV state with 5v presence on one of its USB port (connected on pin2, INT0).
The arduino is powered by a small 5v power supply.
I use IRremote library to send the IR signal to power-on/off the Logitech AudioKit (led on PIN3).
I use an interrupt on CHANGE state to send the IR command...
The sketch and the hardware seem to work well together.
Here is the code and the schematic.
As Arduino developer or expert, would you have done things differently ??
Hard to share an easier code, but may be this is not the good way to proceed...
#include <IRremote.h>
IRsend irsend;
void setup()
{
attachInterrupt(0, PowerButton, CHANGE);
}
void loop()
{
}
void PowerButton()
{
irsend.sendNEC(0x10EF08F7, 32); // The power signal for Z5500
}
loop() is empty. What do you think the Arduino is doing while it's waiting for the interrupt? It's not doing nothing. It's opening loop ten thousand times per second, then closing it. The processor is still clocking along at 16MHz even though you have given it nothing useful to do.
It seems like inefficiency to do a digitalRead() ten thousand times per second but since you aren't asking it to do anything else then you may as well 'use up' the clock cycles with this. There's no need at all for an interrupt in this case.
#include <IRremote.h>
const int InputPin = 2; //Input on pin 2, any time this changes from low to high or high to low, send the IR signal
IRsend irsend;
int LastState;
void setup()
{
 LastState = digitalRead(InputPin);
}
void loop()
{
 int NewState = digitalRead(InputPin);
 if(NewState != LastState) {
  LastState = NewState;
  PowerButton();
 }
 Â
}
void PowerButton()
{
 irsend.sendNEC(0x10EF08F7, 32); // The power signal for Z5500
}
I open this new subject to ask for advice, see if what I did is in good practices and if so, share this tiny sketch with others.
What I want to do is very simple (so sketch too) !
I would like to auto switch-on my Logitech audiokit Z5500 when I switch-on my Samsung LED TV (and switch it off when I switch off the TV), with one remote control (the TV's one) and without hacking the Z5500.
I detect the TV state with 5v presence on one of its USB port (connected on pin2, INT0).
The arduino is powered by a small 5v power supply.
I use IRremote library to send the IR signal to power-on/off the Logitech AudioKit (led on PIN3).
I use an interrupt on CHANGE state to send the IR command...
The sketch and the hardware seem to work well together.
Here is the code and the schematic.
As Arduino developer or expert, would you have done things differently ??
Hard to share an easier code, but may be this is not the good way to proceed...
void PowerButton()
{
irsend.sendNEC(0x10EF08F7, 32); // The power signal for Z5500
}

Thank you very much ! Antoine.
150% of "computers" interact with "outside world" and process the info retrieved. Obviously there are many different ways to do this basic task and using interrupts is just ONE of them.
The objective is not to keep the processor from falling asleep from boredom in Loop() , but to accomplish the task.