Hi,
Overview of my project:
I am building a remote control that is reconfigurable. It has two buttons, if a button is pressed for more than 5 seconds, it is identified as a long press and the Arduino goes into configuration mode.
In the configuration mode function, the Arduino waits for 5 seconds to receive an IR signal (from an outside source), the received signal is then decoded into its 1) protocol, 2) number of bits, and 3) IR HEX values respectively. These values are saved into local variables and are saved into three separate lines in a file in the SD card for the respective button pressed (one being reconfigured).
If the button is pressed for less than 5 seconds, it is detected as a short press and the Arduino sends the hex value received earlier that is associated with that button, using the correct protocol and number of bit codes.
Note: The Arduino doesn't read the values from the file directly every time a button is pressed, instead it reads both files once during setup and stores them into their respective local variables, and during reconfiguration these local variables are updated and the files in the SD card are deleted and updated too.
My problem:
- My Arduino only goes into configuration mode once, meaning if I press button 1 for more than 5 seconds it configures successfully, but then if I try button 2, it doesn't read any values from the IR receiver, and it just stores a raw code of zeros for the value and then exits the configuration mode;
- after trying to reconfigure, if I try a short press it just freezes the whole serial monitor and the Arduino gets restarted (i.e, setup is run again).
I don't know what is causing this issue, there are no errors in the code (compiles fine) and if it can configure once correctly why is it a problem to do it again?
Attempts I've made to fix the problem:
- I thought maybe the issue could be with the memory of the Arduino, I was using an Arduino UNO and switched to a MEGA 2560 (ELEGOO), but I still have the same issue.
- I tried testing parts of the code separately, and had no issue with any individual part, just when all is put together do I get this reset issue.
-I checked the wiring to make sure I didn't accidentally make a mistake in the circuit, but everything turned up to be good.
I attached my code (.ino and doc), and a schematic of what the circuit looks like with the Arduino UNO, and MEGA (note: pins in the picture are not the same I'm using, I just included that as a reference of what mine looks like)
Please let me know if you have any suggestions on how to troubleshoot this problem.
-Note: I am a beginner, and this is the first time I am asking a question on the forum, I apologize if I wrote too much or not enough. Please let me know if you need more information.
Thank you for taking the time to read my question!
Cheers ![]()
IR_Remote_Sketch.doc (54.5 KB)
IR_Send_Samsung_Test_MEGA.ino (18.5 KB)

