Help writing a simple sketch, at power up send 2 RC5 IR sequences

There may be another approach that would work. Since you will be powering the Nano or 85 from a 5V supply, you can directly measure the voltage on the Vcc input, without any external parts, and without dedicating a pin to it, using analogRead(). When the 5V supply starts to sag, you would send the final command.

Both the ATmega328P and the ATtiny85 allow you to read the internal 1.1V bandgap reference voltage with respect to Vcc. Normally, you would measure other voltages with respect to the 1.1V, but the register settings allow you to set the 1.1V bandgap as the voltage being measured, and Vcc as the reference range. So as the input voltage drops, the analogRead() result would increase. The fixed 1.1V reads as a higher percentage of the falling Vcc.

I think in this situation you would put the big capacitor on the 5V rail.

However, you will be drawing a lot of current from the capacitor to transmit the IR signal. I'm just not sure any reasonable capacitor would let you finish the transmission. But I haven't run the numbers, so I may be wrong on that.

1 Like