Problems with Storing Hex Codes

It appears you have your button improperly wired. Rather than connecting the other side to 5V, it needs to be connected to GND. Then, in setup() you need to declare these pins as INPUT_PULLUP so they will normally read HIGH unless the button is pressed and then they will read LOW (You can use the analog pins as digital pins).

The way you have it now, the input is floating when not pressed, so no guarantees what value you will read.

As for the code, if you get a timeout in our waitForIRSignal() function, you never resume receving any future signals.

1 Like