Sir, could you please take a photo of your wiring setup? I'd like to compare the length of your wires and the way you've wired everything up with my own setup.And could you please tell me which version of the Arduino IDE you are using? I'm gradually troubleshooting all the issues.Thank u.
I tried to find on purpose an old breadboard in my kits (it's probably 10 to 15 year old) and the Dupont wires have also been overused and I did not make them short either on purpose.
The UNO is genuine, the MEGA is a clone.
The power comes from the same powered USB hub for both boards.
this has been running for ~14h now and no red light, the green light is still ticking.
as mentioned above wiring is:
UNO 5V <---> + Rail of breadboard (top of the picture)
UNO GND <---> — Rail of breadboard (top of the picture)
MEGA GND <---> — Rail of breadboard (bottom of the picture)
UNO pin 2 <---> MEGA pin 2
UNO pin 3 <---> R 10kΩ <---> + Rail of breadboard ( = UNO 5V)
UNO pin 7 <---> R 200Ω <---> Anode [GREEN LED] Cathode <---> — Rail of breadboard
UNO pin 8 <---> R 200Ω <---> Anode [RED LED] Cathode <---> — Rail of breadboard
A side question as I just re-read the title of your post : The UNO is receiving the pulse and has the pull-up to 5V through the 10KΩ resistor and the MEGA is sending the pulse. So there is no ISR involved on the MEGA side.
Does this match your setup or is it the opposite (ie the MEGA receiving the interrupts)
the version of the IDE does not really matter as it's the same compiler running behind. I've been using the 2.3.3 release as it's easier to have both Serial monitors open at the same time but I'm pretty sure it would be exactly the same with 1.8.19
Thank you so much for your thorough replication and response! You've truly gone above and beyond, even managing to find and utilize a board from 10 to 15 years ago .Alright, let's get back to the main topic. Your setup is exactly the same as mine: the MEGA doesn't utilize an interrupt service routine (ISR), while the UNO, which receives the pulse signal, does. Currently, it appears that your observation is entirely accurate – the red light shouldn't come on because it shouldn't enter that ISR, but mine did, meaning it was falsely triggered. The version of the IDE where I encountered the issue was 2.3.3. I've now switched my IDE to version 1.8 and will try running it again. I'll keep you updated on any developments. Thank you again, I'm really grateful.
I believe my program is free of issues, just like yours, but yours is indeed more standardized and targeted, which makes it very worthwhile for me to learn from you. I think I have basically checked all the possible problems, including replacing the development board, etc. Now, I can only try changing the Arduino IDE version as well. If it still doesn't work after that, I will switch to your program, replicate your setup, and run it again, then inform you of the situation. Thank you very much.
As I wrote before, changing the IDE won’t do much for you, it’s the same compiler anyway at the back of it.
I would double check the quality of your power supply for the Arduinos and make sure you are not running in a noisy environnement (motors, WiFi access point nearby, …)
Thank you very much, I will do as you said and follow through with it.
You should have the shared variable with the ISR as volatile bool (true and false) and ideally use a critical section to read it and reset it in the loop.
I let it run and it’s still ticking fine and no red light. I’ll stop it there. Seems this works as expected.
You likely have a power or interference issue of some sort (flaky wires ?)
Sir, first of all, thank you very much for your reply. I'm still trying. I followed your advice to keep the wires very short and twisted in pairs, but the same issue still occurred. Now I will try to replace the ESP32 to see if that makes a difference. Thank you.
I looked and this seems to be the first mention of the ESP32. The only sense I can make of your statement is that you intend to move away from the Megas and see what happens on the ESP32. Is that right?
I've been watching to see why what should work does not. At this point it would make more sense for you to try @J-M-L's code and see what happens.
a7
(post deleted by author)
Sir, I apologize for not updating you with the latest situation for some time. Recently, I followed your advice and changed them to volatile
types, and I also replaced the USB power port. I am currently conducting tests and will keep you updated on the latest situation at any time. Additionally, despite changing the Arduino version and replacing the ESP32 last week, the same issue still persisted.
I apologize for the delay in my response. Yes, I had intended to look into the ESP32 this week. I will definitely try out the code and see what happens. Thank you for your suggestion.
No apologies needed.
I would not spend time testing 20 different boards, what you experience should not happen regardless of the board or IDE version.